centos7运维 gcc+SCL升级

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-8-gcc.x86_64 devtoolset-8-gcc-c++.x86_64 devtoolset-8-gcc-gdb-plugin.x86_64 

2.4 查看从 SCL 中安装的包的列表

scl --list 
或 scl -l


---------------------------------------------------------------------------------
[root@iZbp177jbnjh3xwkz7ccx7Z ~]# scl --list
devtoolset-8

2.5 切换版本

scl enable devtoolset-8 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

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值