Centos中 Gcc版本升级

Centos升级gcc/g++

gcc 4.9

$ wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo -O /etc/yum.repos.d/devtoolset-3.repo
$ yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-binutils
$ scl enable devtoolset-3 bash

gcc 5.2

$ wget https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-6/hhorak-devtoolset-4-rebuild-bootstrap-epel-6.repo -O /etc/yum.repos.d/devtoolset-4.repo
$ yum install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-binutils -y
$ scl enable devtoolset-4 bash

gcc 6.3

$ yum -y install centos-release-scl
$ yum -y install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
$ scl enable devtoolset-6 bash

需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。
如果要长期使用gcc 6.3的话:

$ echo "source /opt/rh/devtoolset-6/enable" >>/etc/profile

这样退出shell重新打开就是新版的gcc了临时
其他版本同理,修改devtoolset版本号即可。

gcc 7.3

$ yum -y install centos-release-scl
$ yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils
$ scl enable devtoolset-7 bash

需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。
如果要长期使用gcc 7.3的话:

$ echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile
$ . /etc/profile

查看版本:
 $ gcc -v
 
 $ rpm -qa|grep gcc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值