致力于Linux-Win-MacOS系统技术支持及软件,提供开源代码编译服务,搭建部署软件运行环境,HPC计算集群及科研计算类软件编译安装
CentOS 更新升级/降级 安装 GNU  gcc  g++  gfortran 编译器版本
CentOS 更新升级/降级 安装 GNU gcc g++ gfortran 编译器版本

CentOS 更新升级/降级 安装 GNU gcc g++ gfortran 编译器版本

1、添加SCL软件源

yum install centos-release-scl

2、更改SCL软件源为国内镜像源

配置/etc/yum.repos.d/CentOS-SCLo-scl.repo为国内地址

[centos-sclo-sclo]
name=CentOS-7 – SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
CentOS-SCLo-scl-rh.repo

配置/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo为国内地址

[centos-sclo-rh]
name=CentOS-7 – SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

3、安装指定的gnu版本,例如:

yum install devtoolset-7
yum install devtoolset-8
yum install devtoolset-9
yum install devtoolset-10
yum install devtoolset-11

4、激活生效(以版本8示例)

scl enable devtoolset-8 bash

source /opt/rh/devtoolset-8/enable

5、验证gcc版本

此时通过gcc –version命令可以看到,gcc版本已经变成8.x.x

###值得注意的是这仅仅在当前bash生效,如果需要永久生效,可以请自行添加环境变量。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注