This commit is contained in:
68
Docs/Centos-Devtoolset升级Gcc.md
Normal file
68
Docs/Centos-Devtoolset升级Gcc.md
Normal file
@@ -0,0 +1,68 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Centos-Devtoolset升级Gcc
|
||||
|
||||
> 命令行升级方式无需[源码编译](https://ftp.gnu.org/gnu/gcc/)
|
||||
|
||||
1. 安装 centos-release-scl
|
||||
|
||||
```bash
|
||||
yum install centos-release-scl -y
|
||||
```
|
||||
|
||||
2. 安装 devtoolset
|
||||
|
||||
> 查看版本
|
||||
>
|
||||
> ```bash
|
||||
> yum list devtoolset*
|
||||
> ```
|
||||
>
|
||||
> 可安装多个版本切换使用
|
||||
|
||||
```bash
|
||||
yum install devtoolset-11-gcc*
|
||||
```
|
||||
|
||||
3. 启动 devtoolset
|
||||
|
||||
```bash
|
||||
scl enable devtoolset-11 bash
|
||||
```
|
||||
|
||||
4. 查看版本
|
||||
|
||||
```bash
|
||||
gcc -v
|
||||
```
|
||||
|
||||
5. 切换版本
|
||||
|
||||
> 脚本目录在 `/opt/rh/devtoolset-*/enable`
|
||||
|
||||
```bash
|
||||
source /opt/rh/devtoolset-10/enable
|
||||
```
|
||||
|
||||
6. 彻底替换旧的 Gcc, 移除旧的版本
|
||||
|
||||
```bash
|
||||
mv /usr/bin/gcc /usr/bin/gcc.bak
|
||||
mv /usr/bin/g++ /usr/bin/g++.bak
|
||||
```
|
||||
|
||||
7. 创建新的软连接
|
||||
|
||||
```bash
|
||||
ln -s /opt/rh/devtoolset-11/root/bin/gcc /usr/bin/gcc
|
||||
ln -s /opt/rh/devtoolset-11/root/bin/g++ /usr/bin/g++
|
||||
```
|
||||
|
||||
8. 查看版本
|
||||
|
||||
```bash
|
||||
gcc --version
|
||||
g++ --version
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user