關於Ubuntu中gcc g++升級問題

在安裝LLVM clang和linaro-arm-linux-gcc過程中可能會出現

arm-linux-gnueabihf-gcc: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or director

類似問題,這個是因爲系統帶的gcc版本太低了或太高。

如果要使用C++11,Ubuntu12.04 LTS默認GCC G++爲4.6.*版本(本機爲4.6.3版),其不支持最新的c++11標準。

解決辦法:

以下介紹升級GCC/G++:

#加入此源爲必須,否則容易查找不到要升級的版本
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get install gcc-4.8
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

gcc --version
g++ --version
顯示爲升級之後的版本,接下來就可以放心使用-std=c++11命令了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章