您的位置:首页 > 编程语言 > Python开发

使用GDB出现ImportError: No module named 'libstdcxx' 错误提示的解决方案

2015-09-09 17:16 621 查看
【问题描述】

错误提示:

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'


操作系统:Ubuntu 14.04 64-bit

gcc版本:gcc-4.8.4

python版本: 2.7.6

【错误分析】

来自stackoverflow的解释

The script in libstdc++.so.6.0.19-gdb.py ought to be fixed as per that email message, and possibly ported to python 3 (I haven’t looked at it really closely yet). But if your target is compiled with the system version of gcc (i.e. you’re not cross-compiling nor using a version of gcc different from the one that came with the system), you can just do (gdb) python sys.path.append(“/usr/share/gcc-4.8/python”); then it won’t matter that the libstdc++.so.6.0.19-gdb.py script adds a nonexistent directory to the path.

这是个bug在很早的版本,不过新的libstdc++.so.6.0.19-gdb.py已经修复了这个import导入问题,如果还会出现这种问题,可能是交叉编译或者py脚本的gcc编译版本与运行环境不同导致的。

【解决方案】

在gdb控制台中,输入

python sys.path.append("/usr/share/gcc-4.8/python");


【感悟】

gdb打印居然是依赖python库文件,好神奇啊。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  gdb python