linux 出现相似常见问题ImportError: libxxx: 或 'GLIBCXX_3.4.21' not found 的解决方法

常见相似问题: ImportError: libxxx: cannot open shared object file: No such file or directory

缘由1:可能路径未配置正确linux

解决方法:找到libxxx安装的目录,将目录添加到环境变量LD_LIBRARY_PATHc++

[root@myserver ~]# find / -name libffi*
/usr/local/lib64/libffi.so.6
/root/libffi-3.2.1/x86_64-unknown-linux-gnu/.libs/libffi.so.6
...
[root@myserver~]# echo $LD_LIBRARY_PATH
[root@myserver~]# export LD_LIBRARY_PATH=”/usr/local/lib64/”

缘由2: 未安装该库,或版本太低ide

解决方法code

  • 查看适配的版本 yum whatprovides libxxx
[root@kefu1013 thoth-ai]# yum whatprovides libXrender.so.1
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.nwsuaf.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: ap.stykers.moe
libXrender-0.9.10-1.el7.i686 : X.Org X11 libXrender runtime library
Repo        : base
Matched from:
Provides    : libXrender.so.1
  • 安装相应版本

yum install libXrender-0.9.10-1.el7.i686server

  • 出现相似错误:ImportError: libxxx: wrong ELF class: ELFCLASS32

安装64位 yum install libXrender-0.9.10-1.el7.x86_64rem

  • 出现相似错误:ImportError: libxxx: wrong ELF class: ELFCLASS64

安装32位 yum install libXrender-0.9.10-1.el7.i686 或 yum install libXrender-0.9.10-1.el7.i386string

  • 其它相关命令:

查看是否为64位文件 file topas /usr/lib/libxxxio

卸载已经安装的 yum remove libxxx编译

常见相似问题:/usr/lib64/libstdc++.so.6: version 'GLIBCXX_3.4.21' not found

缘由1:已经安装太高版本但未软链接ast

解决方法:查找编译gcc时生成的最新动态库

find / -name "libstdc++.so*" 输出:

/home/gcc-5.2.0/gcc-temp/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/home/gcc-5.2.0/gcc-temp/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/home/gcc-5.2.0/gcc-temp/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21  //最新动态库
……

将最新动态库复制到 /usr/lib64目录下:

cp /..../libstdc++.so.6.0.21 /usr/lib64

复制后将新动态库进行软链接:

cd /usr/lib64

ln -s libstdc++.so.6.0.21 libstdc++.so.6

缘由2:版本低

解决方法:

  • 查看gcc版本中包含哪些库。

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
...
  • 从网上下载高版本的libstdc++.so.6.0.13以上的版本,好比libstdc++.so.6.0.17。(或者从其它机器上拷贝一份)

  • 把libstdc++.so.6.0.17拷贝到/usr/lib64目录下。

  cp libstdc++.so.6.0.17 /usr/lib64/

  • 删除libstdc++.so.6符号链接。(也能够不删)

  rm libstdc++.so.6

  • 新建里符号链接。

ln -s libstdc++.so.6.0.17 libstdc++.so.6

  • 再次查看就没有问题了。
相关文章
相关标签/搜索