更新系统
yum -y update
yum groupinstall -y development
yum install -y libmpc-devel mpfr-devel gmp-devel
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
下载并安装
wget https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
tar xzf gcc-7.2.0.tar.gz
cd gcc-7.2.0
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8
make install
查看是否安装成功
[root@hostname gcc-7.2.0]# gcc --version
gcc (GCC) 7.2.0
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.