下午,為了使用C++11某些特性,不得不安裝更高版本的gcc4.7 或gcc 4.8
有兩種方法:
一、通過下載源碼的方式安裝,不過這個有點麻煩,而且容易出問題,推薦第二個方案
二、安裝devtoolset-2工具
具體步驟:
1、Save repository information as /etc/yum.repos.d/slc6-devtoolset.repo on your system,then install it using yum
wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo yum install devtoolset-2
2、在安裝過程中出現了錯誤:找不到相關的GPG key,只要根據提示安裝相應的GPG key 即可
rpm --import http://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-cern rpm --import http://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-sl
3、重新安裝即可
4、export
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/ hash -r gcc --version
備注:
需要參考的幾個網址: