1、编辑/etc/resolv.conf, 保证能ping通外网,如baidu
2、直接参考如下帖子,我没有成功,不知道啥原因
Centos7 安装gcc8的步骤(2024年6月30日后)_centos7安装gcc8-CSDN博客
https://blog.csdn.net/qq_45972323/article/details/144328345
报没有找到包
3、于是尝试先装centos-release-scl,再装gcc
但是装gcc的时候,还是报错:
4、更换yum源不成功
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 24279 0 --:--:-- --:--:-- --:--:-- 24735
[root@localhost ~]# um clean all
-bash: um: command not found
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base centos-sclo-rh centos-sclo-sclo extras updates
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
5、这是再按照那个帖子搞下,成功了!
[root@localhost ~]# yum install devtoolset-8
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
(详细过程不记录了)
Total download size: 95 M
Is this ok [y/d/N]: y
Downloading packages:
6、使能安装后的gcc
source /opt/rh/devtoolset-8/enable,并将其加入到~/.bashrc中