版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012750702/article/details/52904566
环境:ubuntu16.04 64位
问题描述:
运行别人/别的电脑编译好的可执行文件时,终端输出错误:
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
解决方案:
类似error while loading shared libraries: xxx: cannot open shared object file: No such file or directory的错误都可参考如下方法:
1、首先使用如下命令查找该库(以libstdc++.so.6为例)所在的包
<span style="font-size:12px;">$ apt-file search libstdc++.so.6</span>
找到后终端会返回结果,有很多就不全列出了,左边是包,右边是库
gcc-snapshot: /usr/lib/gcc-snapshot/lib/debug/libstdc++.so.6
gcc-snapshot: /usr/lib/gcc-snapshot/lib/debug/libstdc++.so.6.0.22
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.22
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.22-gdb.py
...
2、安装需要的
$ sudo apt-get install gcc-snapshot
特别注意:
运行命令apt-file search xxx时可能出现如下错误:
The program 'apt-file' is currently not installed. You can install it by typing:
sudo apt install apt-file
这时需要根据提示执行
$ sudo apt install apt-file
$ apt-file update
即可。