1. 程式人生 > >Centos6.9 升級gcc4.8.1完整版 與 tensorflow執行出現'GLIBCXX_3.4.19' not found錯誤

Centos6.9 升級gcc4.8.1完整版 與 tensorflow執行出現'GLIBCXX_3.4.19' not found錯誤

centos升級gcc到4.8.1(支援c++11)完整版

安裝步驟:

下載gcc最新版

然後解壓到資料夾

tar -xvzf gcc-4.8.1.tar.gz

進入解壓縮之後的目錄

cd gcc-4.8.1

然後執行下面的執行

./contrib/download_prerequisites

再返回上一層,建立build_gcc_4.8.1目錄,這個目錄和gcc-4.8.1平行

cd ..
mkdir build_gcc_4.8.1

進入剛建立的目錄,並執行編譯過程

cd build_gcc_4.8.1

../gcc-4.8.1/configure –enable-checking=release –enable-languages=c,c++
–disable-multilib

make -j4
make install

OK,在build_gcc_4.8.1中將gcc已經安裝完成

確定新安裝的GCC的路徑,之前安裝時記下最後mv時的路徑即可

用which gcc 可查詢到安裝的路徑

使用ls /usr/local/bin | grep gcc檢視安裝的版本

/usr/sbin/update-alternatives –install /usr/bin/gcc gcc /usr/local/bin/x86_64-unknown-linux-gnu-gcc-4.8.1 40

gcc –version #檢視版本

/usr/sbin/update-alternatives –install /usr/bin/g++ g++ /usr/local/bin/g++ 40

g++ –version #檢視版本

升級完gcc4.8.1後 仍出現’GLIBCXX_3.4.19’ not found錯誤

執行: # strings /usr/lib64/libstdc++.so.6|grep GLIBCXX
羅列的版本沒有相應的版本,需要執行 以下操作:

轉到上面解壓的資料夾下找檔案:libstdc++.so.6.0.18

我的目錄是這個,具體可能有所差異,執行命令:
cd /root/situ/gcc-build-4.8.1/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
進入檔案目錄
用下面的命令檢視版本:
strings libstdc++.so.6|grep GLIBCXX
一般來講,裡面就有滿足需要的GLIBCXX版本了。

有的話,ls找最高版的libstdc++.so.6.0.*檔案,我的是libstdc++.so.6.0.19
然後,把該檔案拷貝到了/usr/lib64下,執行命令拷貝:
cp libstdc++.so.6.0.19 /usr/lib64

將libstdc++.so.6指向libstdc++.so.6.0.19:

切換至工作目錄:cd /usr/lib64
重新指向:
rm -r libstdc++.so.6
ln -s libstdc++.so.6.0.19 libstdc++.so.6
這樣就可以正常用到了
預設動態庫升級完成。重新執行以下命令檢查動態庫:

strings /usr/lib64/libstdc++.so.6 | grep GLIBC
輸出就有想要的版本了
其他的報錯資訊ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.9’ not found (required by錯誤可參考:
https://blog.csdn.net/ccbrid/article/details/78979878