centos7升级GCC版本

Devtoolset是红帽提供的开发工具集合,用于在旧版CentOS上使用新版本的GCC。例如,devtoolset-8对应GCC8.x.x版本。安装可通过yum安装centos-release-scl和devtoolset-8包,或者手动编辑yum源。激活GCC版本使用sclenabledevtoolset-8bash或sourcing相关文件。注意,这仅在当前会话生效,要持久化需设置环境变量。
摘要由CSDN通过智能技术生成

devtoolset对应gcc的版本

devtoolset-3对应gcc4.x.x版本
devtoolset-4对应gcc5.x.x版本
devtoolset-6对应gcc6.x.x版本
devtoolset-7对应gcc7.x.x版本
devtoolset-8对应gcc8.x.x版本
devtoolset-9对应gcc9.x.x版本
devtoolset-10对应gcc10.x.x版本

可通过centos-release-scl源安装devtoolset包

yum install centos-release-scl
yum install devtoolset-8

或自行添加源来安装(我这里以CentOS7为例)

vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

激活gcc版本,使其生效

scl enable devtoolset-8 bashsource /opt/rh/devtoolset-8/enable

此时通过gcc --version命令可以看到,gcc版本已经变成8.x.x,值得注意的是这仅仅在当前bash生效,如果需要永久生效,可以请自行添加环境变量。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值