วิธีลง GCC ใน Solaris 11

เคยเขียนวิธี set PATH Solaris เพื่อ configure กับ make fileมาแล้วรอบนึง ตอนนั้นเครื่องที่ใช้เป็น Solaris 10 ที่ลง GCC ไว้อยู่แล้ว (จำไม่ได้ว่าลงตอนไหน) ตอนนี้เครื่องปัจจุบันเป็น Solaris 11 ที่ลงเอง พอดีจะลง Python 2.7 เพื่อที่จะใช้ argparse เพราะว่า Python 2.6.8 ที่ Sol มันลงมาให้ยังไม่มี ซึ่ง package ของ Solaris มันไม่มีให้ download ก็เลยต้องโหลด code มา compile เอาเองก็เลยเพิ่งรู้ว่า default installation ของ Sol11 แม่งไม่ลง gcc ให้ – -”

ค้นไปค้นมาก็ไปได้วิธีลงมาจากwiki ของ nginx ซะงั้น วิธีการก็ตามนี้ครับ

  1. กรณีที่ต่อ internet ผ่าน proxy ก็ให้ set proxy ด้วยคำสั่ง
    $> export http_proxy=http://xxx:yyy
    

    ใส่ ip กับ port ไปใน xxx:yyy ข้างบนฮะ

  2. เปลี่ยนมาเป็น root account
  3. ลง gcc ด้วยคำสั่ง
    $> pkg install gcc-45
    
  4. รอมันลงเสร็จก็จบล่ะ

หลังจากลงเสร็จเราก็ไป set PATH ไปที่ /usr/ccs/bin:/usr/sfw/bin ตาม link ข้างบนเพื่อให้ใช้คำสั่ง configure และ make ได้ครับ

วิธี set PATH Solaris เพื่อ configure กับ make file

ช่วงนี้มีเรื่องให้ต้อง compile โปรแกรมบน Solaris 10 x86 แล้วก็ติดปัญหาเรื่อง set compiler path หลายครั้งจนขอจดไว้ต้อง set อะไรบ้าง

พอโหลด source มา untar file เสร็จสั่ง configure ก็ขึ้นแบบนี้มาเลย

# ./configure
checking build system type... i386-pc-solaris2.10
checking host system type... i386-pc-solaris2.10
checking target system type... i386-pc-solaris2.10
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/disk2/opt/ruby':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
#

ไปค้นๆ ดู ต้องไปหา gcc ครับ ซึ่ง default ของ Solaris ในกรณีที่ไม่ได้ลง Sun Studio มันอยู่ที่ /usr/sfw/bin เราก็ export PATH ไป

# export PATH=/usr/sfw/bin:$PATH

พอสั่ง ./configure ก็จะเจอ error ว่าไม่มี make -*-

checking for prefix of external symbols... ./configure: line 18702: conftest.o: command not found
NONE
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking if make is GNU make... ./configure: line 18909: make: command not found
no
checking for safe null command for make... configure: error: no candidate for safe null command

ไปค้นๆ ดู make ไม่ได้อยู่ใน /usr/sfw/bin แต่อยู่ใน /usr/ccs/bin ต่างหาก -*-

ดังนั้นวิธีการ export ที่ถูกต้องเพื่อที่จะ configure และ make ได้คือ

# export PATH=/usr/ccs/bin:/usr/sfw/bin:$PATH

ที่นี่ก็จะ build ได้ พอ make install โปรแกรมก็จะไปอยู่ใน /usr/local แล้วเราก็ค่อยไปสร้าง softlink อีกทีครับ

วิธีเปิด file .tar.gz

สิบกว่าปีในชีวิตการทำงานของผม ผมเปิด file .tar.gz ด้วยวิธีนี้เสมอ

$> gunzip file.tar.gz
$> tar -xvf file.tar

ผมใช้วิธีนี้มาตลอดโดยสงสัยว่าทำไมมัน pipe คำสั่งกันไม่ได้วะ แต่ก็ยัง gunzip มันอยู่จนกระทั่ง @rtsp, @sikachu และ @somkiat บอกผมว่า “ทำไมไม่ใช้ tar -zxvf?”

$> tar -zxvf file.tar.gz

โอ มันง่ายกว่าจริงๆ ;__;

ขอขอบคุณ @rtsp, @sikachu และ @somkiat มานะทีนี้