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)

 

posted @ 2014-11-03 08:58  pugna  阅读(9396)  评论(0编辑  收藏  举报