1、环境说明
[root@iZbp177jbnjh3xwkz7ccx7Z yum.repos.d]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@iZbp177jbnjh3xwkz7ccx7Z yum.repos.d]# lsb_release -
[root@iZbp177jbnjh3xwkz7ccx7Z yum.repos.d]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core
2、安装步骤
2.1 安装scl源
yum install -y centos-release-scl scl-utils-build
添加yum源
sudo tee /etc/yum.repos.d/CentOS-SCLo-scl.repo <<-'EOF'
[sclo]
name=sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
enabled=1
EOF
sudo tee /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo <<-'EOF'
[sclo-rh]
name=sclo-rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
enabled=1
EOF
2.2 列出scl有哪些源可以用
yum list all --enablerepo='sclo-rh'
yum list all --enablerepo='rh'
-------------------------------------------------------------
7\8\9\10\11都可以使用
2.3 安装7版本的gcc、gcc-c++、gdb
yum install -y devtoolset-7-gcc.x86_64 devtoolset-7-gcc-c++.x86_64 devtoolset-7-gcc-gdb-plugin.x86_64
2.4 查看从 SCL 中安装的包的列表
scl --list 或 scl -l
---------------------------------------------------------------------------------
[root@iZbp177jbnjh3xwkz7ccx7Z ~]# scl --list
devtoolset-7
2.5 切换版本
scl enable devtoolset-7 bash
2.6 查看
[root@iZbp177jbnjh3xwkz7ccx7Z yum.repos.d]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2.7 退出
使用exit 退出当前scl版本的bash环境
2.8 永久生效
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-7/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-7/root/bin/g++ /usr/bin/g++
gcc --version
g++ --version
标签:bin,SCL,gcc,scl,--,devtoolset,centos7,yum
From: https://blog.csdn.net/weixin_44663310/article/details/140858308