yum install gcc -y
yum install gcc-c++ -y
yum install bzip2
cd /tmp
wget http://mirror.hust.edu.cn/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
tar xvf gcc-7.2.0.tar.gz -C /root
cd /root/gcc-7.2.0/
./contrib/download_prerequisites (下载较慢,成功会有提示)
mkdir build
cd build/
../configure --prefix=/usr/local/gcc7 --enable-languages=c,c++,go --disable-multilib
make
make install
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /usr/local/gcc7/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /usr/local/gcc7/bin/g++ /usr/bin/g++