一、使用yum安装默认gcc
因为编译安装gcc,是需要用gcc编译的,所以首先需要安装默认gcc
yum install gcc
yum install gcc-c++
如果没有yum源,可以先配置阿里源
cd /etc/yum.repo.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 重新加载yum源
yum clean all
yum makecache
二、安装指定版本gcc
1. 下载gcc(选用清华源)
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz