资料http://people.centos.org/tru/devtools-2/readme
步骤
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
软件会被安装在/opt/rh目录下
然后配置用户环境
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/c++
ln -sv /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin
切换gcc
update_alternatives –install /usr/bin/gcc gcc /usr/local/bin/gcc 100
另外可以直接编译安装新版的gcc