出處:http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos
執行以下指令
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
成功後安裝于目錄
/opt/centos/devtoolset-1.1/root/usr/bin/
版本為 4.7.2
設定環境變量取代預設gcc:
export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
有些源代碼依賴于較高的gcc版本,這是解決辦法。
gcc 4.8.1和4.8.2在此:https://people.centos.org/tru/devtools-2/
參考上述辦法安裝。