使用Centos官方源安装:
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -P /etc/yum.repos.d
yum install devtoolset-2-gcc
yum install devtoolset-2-gcc-c++
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-2/root/usr/bin/g++
编译安装GCC:
yum install gmp-devel mpfr-devel libmpc-devel
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz
tar zxf gcc-4.8.2.tar.gz
cd gcc-4.8.2
./configure --enable-languages=c,c++ --disable-multilib
make && make install