添加 'linux基础/Centos7升级gcc版本.md'
This commit is contained in:
parent
4b9507e114
commit
4249c1249b
1 changed files with 48 additions and 0 deletions
48
linux基础/Centos7升级gcc版本.md
Normal file
48
linux基础/Centos7升级gcc版本.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
**Red Hat Developer Toolset是RedHat开发工具包,可以多版本gcc共存,不影响原系统gcc环境**
|
||||
## 安装Red Hat Developer Toolset
|
||||
```shell
|
||||
yum -y install centos-release-scl-rh
|
||||
```
|
||||
|
||||
## 配置软件源
|
||||
```shell
|
||||
cat > CentOS-SCLo-scl-rh.repo << EOF
|
||||
[centos-sclo-rh]
|
||||
name=CentOS-7 - SCLo rh
|
||||
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/sclo/$basearch/rh/
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
|
||||
EOF
|
||||
```
|
||||
|
||||
## 生成缓存
|
||||
```shell
|
||||
yum makecache
|
||||
```
|
||||
|
||||
## 安装相应版本
|
||||
```
|
||||
# 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版本
|
||||
|
||||
# 安装gcc-10
|
||||
yum -y install devtoolset-10
|
||||
```
|
||||
|
||||
## 使gcc版本生效
|
||||
```shell
|
||||
# 以下两条命令效果相同
|
||||
# 只在当前shell中生效
|
||||
scl enable devtoolset-8 bash
|
||||
source /opt/rh/devtoolset-8/enable
|
||||
# 当前用户生效
|
||||
cat >> ~/.bash_profile << EOF
|
||||
source /opt/rh/devtoolset-8/enable
|
||||
EOF
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue