出處:http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centosc++
執行如下命令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/bash
版本爲 4.7.2code
設置環境變量取代默認gcc:get
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版本,這是解決辦法。io
gcc 4.8.1和4.8.2在此:https://people.centos.org/tru/devtools-2/
參考上述辦法安裝。class