GCC升級


系統:CentOS-6.5-x86_64-minimal

為了使用c++11特性,升級gcc.

wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2
tar -xjvf gcc-4.9.2.tar.bz2
cd gcc-4.9.2.tar.bz2
./configure

wget下載慢,服務器也是日本的,可以用QQ旋風或迅雷下載,再psftp上傳,

出現錯誤:

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. 

安裝gmp、mpfr、mpc

下載地址:

http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/gmp-4.3.2.tar.bz2
http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/mpfr-2.4.2.tar.bz2
http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/mpc-0.8.1.tar.gz

解壓后逐個安裝,

./configure
make
make install

再次錯誤,

The following languages will be built: c,c++,fortran,java,lto,objc
*** This configuration is not supported in the following subdirectories:
     gnattools target-libada target-libgo target-libbacktrace
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... no
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit developement libraries (libc and headers).
If you have them, rerun configure with --enable-multilib.
If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

系統沒有32位開發支持庫,可以運行yum install glibc-devel.i686安裝,不過我這里不需要編譯32位程序,直接

./configure --disable-multilib

這回配置完成,

make

出現錯誤,

checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock
make[2]: *** [configure-stage1-zlib] Error 1
make[2]: Leaving directory `/root/gcc-4.9.2'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/root/gcc-4.9.2'
make: *** [all] Error 2

更新時間,

ntpdate cn.pool.ntp.org

繼續

make

約半小時后,出現錯誤,

checking for suffix of object files... configure: error: in `/root/gcc-4.9.2/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/root/gcc-4.9.2'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/root/gcc-4.9.2'
make: *** [all] Error 2

查看config.log,發現在配置libgcc時出錯了,yum list libgcc,發現已安裝libgcc.x86_64,難道要裝i686的?go~

yum install libgcc.i686

繼續

make

約四小時這樣子就編譯完成了,

make install

幾分鍾就安裝完成。

看效果

gcc -v 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --disable-multilib
Thread model: posix
gcc version 4.9.2 (GCC)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM