centos6.5 升级gcc

最近有需要升级gcc,原来gcc是4.4.7的,现在需要升级到4.8.5

1. 下载gcc源码包

axel是一个高速下载工具,wget的替代品

axel –n 20 http://mirror0.babylon.network/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz

tar zxvf gcc-4.8.5.tar.gz

cd gcc-4.8.5

./configure

出现以下错误

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

2. 下载 gmp, mpfr, mpc

axel -n 10  http://mirror.hust.edu.cn/gnu/gmp/gmp-6.1.0.tar.xz

xz -d gmp-6.1.0.tar.xz

axel -n 10 http://mirror.hust.edu.cn/gnu/mpfr/mpfr-3.1.4.tar.gz

tar zxf mpfr-3.1.4.tar.gz

wget http://mirror.hust.edu.cn/gnu/mpc/mpc-1.0.3.tar.gz

tar zxf mpc-1.0.3.tar.gz

安装gmp

cd gmp-6.1.0

./configure

make

make install

cd ..

 

安装mpfr, 依赖于gmp安装完成

cd mpfr-3.1.4

./configure

make

make install

cd ..

 

安装mpc, 依赖于gmp, mpfr安装完成

cd mpc-1.0.3

./configure

make

make install

cd ..

 

3. 安装gcc

先用gcc -v看一下之前的gcc编译选项是怎样的,然后根据自己的需要适当修改

gcc –v

./configure --prefix=/usr \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info \
    --with-bugurl=http://bugzilla.redhat.com/bugzilla \
    --enable-bootstrap \
    --enable-shared \
    --enable-threads=posix \
    --enable-checking=release \
    --with-system-zlib \
    --enable-__cxa_atexit \
    --disable-libunwind-exceptions \
    --enable-gnu-unique-object \
    --enable-languages=c,c++,objc,obj-c++ \
    --disable-dssi \
    --enable-libgcj-multifile \
    --enable-java-maintainer-mode  \
    --disable-libjava-multilib \
    --with-ppl \
    --with-cloog \
    --with-tune=generic \
    --with-arch_32=i686 \
    --build=x86_64-redhat-linux

make –j 8 #开启多线程编译, 此步骤需要非长久的时间, 据说70分钟左右, 我没有等到做别的事情了

make install

 

 

 

异常:

1. mpfr进行./configure的时候报error:gmp.h can't be found, or is unusable.

gmp没有安装完成

2. gcc的时候报 configure: error: cannot compute suffix of object files: cannot compile

添加环境变量

vi /etc/profile

加入下面一行

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

保存后source使其生效

source /etc/profile

3. /usr/include/gnu/stubs.h:7:27: 致命错误:gnu/stubs-32.h:没有那个文件或目录

yum -y install glibc-devel.i686

posted @ 2016-04-08 09:04  bojoyzhou  阅读(1623)  评论(0编辑  收藏  举报