GCC升級

系統:CentOS-6.5-x86_64-minimaljava

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

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上傳,c++

出現錯誤:bootstrap

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服務器

下載地址:app

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

解壓後逐個安裝,ide

./configure
make
make install

再次錯誤,ui

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位程序,直接spa

./configure --disable-multilib

這回配置完成,debug

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)
相關文章
相關標籤/搜索