错误排查: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)

感谢阅读

发布了113 篇原创文章 · 获赞 23 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_45409343/article/details/105195130