升级gcc-6.3.0
系统版本:CentOS6.4
GCC版本:4.4.7 -->6.3.0
编译安装依赖包:
gcc依赖gmp、mpfr、mpc包
编译gmp:
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
tar xvf gmp-6.1.2.tar.xz cd gmp-6.1.2
./configure --prefix=/usr/local/gmp
make && make install
编译mpfr:
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.5.tar.gz
tar xvf mpfr-3.1.5.tar.gz
cd mpfr-3.1.5
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make && make install
编译mpc:
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
tar xvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp -with- mpfr=/usr/local/mpfr
make && make install
编译安装Gcc 6.3.0:
执行完./configure之后修改/etc/ld.so.conf文件,指定gcc所需要的依赖包lib目录
添加:
/usr/lib64 #默认
/usr/local/gmp/lib
/usr/local/mpfr/lib
/usr/local/mpc/lib
( yum install libgcc.i686 #上边还不行就安装libgcc)
添加保存后更新动态库的缓存
ldconfig -v
之后再make -j8 && make install
wget ftp://ftp.gnu.org/gnu/gcc/gcc-6.3.0/gcc-6.3.0.tar.gz
tar xvf gcc-6.3.0.tar.gz
cd gcc-6.3.0
./configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++,fortran --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc
–enable-languages=c,c++,fortran:支持的语言
make -j8 make对多核处理器的优化选项,此步骤非常耗时
make install
编译完成后,备份系统默认的gcc版本
mv /usr/bin/gcc /usr/bin/gcc-bak
mv /usr/bin/g++ /usr/bin/g+±bak
mv /usr/bin/c++ /usr/bin/c+±bak
创建gcc的软连接
ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc/bin/c++ /usr/bin/c++
ln -s /usr/local/gcc/bin/g++ /usr/bin/g++
ln -s /usr/local/gcc/lib64/libstdc++.so.6.0.22 /usr/lib64/libstdc++.so.6
查看gcc版本
gcc -v
下一篇: LinkedSet