centos7 升级gcc 7.2

1、gcc安装包获取

gcc-7.2 版本下载地址:http://gcc.parentingamerica.com/releases/gcc-7.2.0/gcc-7.2.0.tar.gz

2、安装依赖包

isl-0.16.1.tar.bz2

gmp-6.1.0.tar.bz2

mpfr-3.1.4.tar.bz2

mpc-1.0.3.tar.bz2

依赖包下载地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/

安装 isl-0.16.1.tar.bz2

tar -jzvf isl-0.16.1.tar.bz2

cd isl-0.16.1

./configure

make

make install

安装 gmp-6.1.0.tar.bz2

tar -jxvf gmp-6.1.0.tar.bz2

cd gmp-6.1.0

mkdir temp

cd temp

../configure --prefix=/usr/local/gmp-6.1.0

make

make install

安装 mpfr-3.1.4.tar.bz2

tar -jxvf mpfr-3.1.4.tar.bz2

cd mpfr-3.1.4

mkdir temp

cd temp

../configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.1.0

make

make install

安装 mpc-1.0.3.tar.bz2

tar -jxvf mpc-1.0.3.tar.bz2

cd mpc-1.0.3

mkdir temp

cd temp

../configure --prefix=/usr/local/mpc-1.0.3 --with-mpfr=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.1.0

make

make install

依赖安装完成,配置依赖参数

vim /etc/profile

在文件尾添加:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.0/lib:/usr/local/mpfr-3.1.4/lib

确保路径与实际安装路径一致。

执行:

source /etc/profile


3、安装gcc

tar -zxvf gcc-7.2.0.tar.gz

cd gcc-7.2.0

mkdir gcc-7.2-build

cd gcc-7.2-build

../configure --prefix=/usr/gcc-7.2.0 --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3

make

make install

安装完成,init 6 重启

4、配置gcc

使用新版gcc、g++ 替换老版本

mv /usr/bin/gcc /usr/bin/gcc.bak

ln -s /usr/gcc-7.2.0/bin/gcc /usr/bin/gcc

mv /usr/bin/g++ /usr/bin/g++.bak

ln -s /usr/gcc-7.2.0/bin/g++ /usr/bin/g++

update-alternatives --install /usr/bin/cc cc /usr/gcc-7.2.0/bin/gcc 999 

更新动态库

cp gcc-7.2.0/output/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.24 /usr/gcc-7.2.0/lib64/libstdc++.so.6.0.24

rm -rf libstdc++.so.6

ls -s libstdc++.so.6.0.24libstdc++.so.6


echo '/usr/local/lib/' > /etc/ld.so.conf.d/local-lib64.conf

ldconfig -v 


5、安装完成

$ gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gcc-7.2.0/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/usr/gcc-7.2.0 --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3
Thread model: posix
gcc version 7.2.0 (GCC)


转载地址:https://blog.csdn.net/weixin_39704301/article/details/78448349

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值