From 4249c1249b00021c69250331a1398885393a3070 Mon Sep 17 00:00:00 2001 From: iProbe Date: Thu, 7 Dec 2023 19:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'linux=E5=9F=BA=E7=A1=80/C?= =?UTF-8?q?entos7=E5=8D=87=E7=BA=A7gcc=E7=89=88=E6=9C=AC.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linux基础/Centos7升级gcc版本.md | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 linux基础/Centos7升级gcc版本.md diff --git a/linux基础/Centos7升级gcc版本.md b/linux基础/Centos7升级gcc版本.md new file mode 100644 index 0000000..c394f12 --- /dev/null +++ b/linux基础/Centos7升级gcc版本.md @@ -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 +``` \ No newline at end of file