錯誤排查:ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found

錯誤排查:ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20’ not found (required by /usr/local/python3/lib/python3.6/site-packages/easyedge_security.cpython-36m-x86_64-linux-gnu.so)

起因:工作中,部署環境遇到以上錯誤,上網遍歷無果(網上寫的真的沒啥用,找了一大推沒一個能用的。。。。)

解決:

根據錯誤信息可知,是GLIBCXX_3.4.20缺失,通過篩選strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX發現的確如此(實驗機裝的是gcc3.8.5,GLIBCXX動態庫只到3.4.19)

既然缺東西那就裝唄~~~~

實操升級gcc庫

一、下載gcc-6.1.0包及其依賴庫(國內源)
wget http://mirror.hust.edu.cn/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gz

# 依賴庫可通過查看gcc軟件包中contrib/download_prerequisites獲得
wget http://mirror.hust.edu.cn/gnu/mpfr/mpfr-2.4.2.tar.gz
wget http://mirror.hust.edu.cn/gnu/gmp/gmp-4.3.2.tar.gz
wget http://mirror.hust.edu.cn/gnu/mpc/mpc-1.0.1.tar.gz
二、配置環境變量,準備安裝
tar zxf gcc-6.1.0.tar.gz
tar zxf gmp-4.3.2.tar.gz
mv gmp-4.3.2/ gcc-6.1.0/
cd gcc-6.1.0/
ln -sf gmp-4.3.2/ gmp
cd
tar zxf mpfr-2.4.2.tar.gz
mv mpfr-2.4.2 gcc-6.1.0
cd gcc-6.1.0/
ln -sf mpfr-2.4.2/ mpfr
cd
tar zxf mpc-1.0.1.tar.gz
mv mpc-1.0.1 gcc-6.1.0
cd gcc-6.1.0/
ln -sf mpc-1.0.1/ mpc
cd
vi /etc/profile
# 全局環境變量文末添加
	export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/gcc-6.1.0/mpc:/root/gcc-6.1.0/gmp:/root/gcc-6.1.0/mpfr

source /etc/profile
三、建立安裝目錄,進行安裝
cd gcc-6.1.0/
mkdir build
./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
# 該步驟異常耗費時間
make && make install

此時,鍵入命令gcc -vg++ -v依舊還是原來的版本

# gcc版本
[root@localhost ~]# gcc -v
使用內建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目標:x86_64-redhat-linux
配置爲:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
線程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)

# gcc-c++版本
[root@localhost ~]# g++ -v
使用內建 specs。
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目標:x86_64-redhat-linux
配置爲:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
線程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)

想要使更新的gcc庫生效則需要接下來的步驟:

cp /usr/local/lib64/libstdc++.so.6.0.22 /lib64
cd /lib64
rm -rf libstdc++.so.6
ln -s libstdc++.so.6.0.22 libstdc++.so.6

此時,大功告成!!!!!!!!!!!

# 新的gcc版本
[root@localhost utils]# gcc -v
使用內建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
目標:x86_64-pc-linux-gnu
配置爲:./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
線程模型:posix
gcc 版本 6.1.0 (GCC)

# 新的gcc-c++版本
[root@localhost utils]# g++ -v
使用內建 specs。
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
目標:x86_64-pc-linux-gnu
配置爲:./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
線程模型:posix
gcc 版本 6.1.0 (GCC)

感謝閱讀

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