GDB: ImportError: 找不到 libstdcxx.v6.printers 模块

3

我在Windows 7上安装了MSYS2和MinGW64。

gdb报告“ImportError: No module named libstdcxx.v6.printers”:

$ gdb  
GNU gdb (GDB) 7.11.1  
Copyright (C) 2016 Free Software Foundation, Inc.  
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>  
This is free software: you are free to change and redistribute it.  
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"  
and "show warranty" for details.  
This GDB was configured as "x86_64-pc-msys".  
Type "show configuration" for configuration details.  
For bug reporting instructions, please see:  
<http://www.gnu.org/software/gdb/bugs/>.  
Find the GDB manual and other documentation resources online at:  
<http://www.gnu.org/software/gdb/documentation/>.  
For help, type "help".  
Type "apropos word" to search for commands related to "word".  
Traceback (most recent call last):  
  File "<string>", line 3, in <module>  
ImportError: No module named libstdcxx.v6.printers  
/etc/gdbinit:6: Error in sourced command file:  
Error while executing Python code.  
(gdb) quit  

我找到了几个链接:

导入错误:没有名为libstdcxx的模块

使用ncurses调试项目时出现“ImportError: No module named 'libstdcxx'”

如何在Eclipse CDT中启用C++ STL对象的gdb漂亮打印?

https://askubuntu.com/questions/345873/gdb-crashes-with-importerror-no-module-named-libstdcxx-v6-printers

https://github.com/Alexpux/MINGW-packages/issues/383

但是它们都没有帮助。

更新:

有2个gdbinit文件。

C:\Appl\msys64\etc\gdbinit:

python
import sys
sys.path.insert(0, sys.path[0] + '/../../gcc-6.3.0/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

C:\Appl\msys64\mingw64\etc\gdbinit:

python
import sys
sys.path.insert(0, sys.path[0] + 'C:/Appl/msys64/mingw64/share/gcc-7.1.0/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
end

/etc/gdbinit 文件的第 6 行是什么? - Mark Plotnick
@MarkPlotnick,我已经找到了其中的两个。请查看更新的帖子。 - KonstantinL
@MarkPlotnick,找到了:C:\Appl\msys64\mingw64\share\gcc-7.1.0\python\libstdcxx;v6子目录存在,并且包含printers.py文件。 - KonstantinL
我应该写类似于 sys.path = 'C:/Appl/msys64/mingw64/share/gcc-7.1.0/python' 这样的代码吗? - KonstantinL
2
尝试使用 sys.path.insert(0, 'C:/Appl/msys64/mingw64/share/gcc-7.1.0/python') - Mark Plotnick
显示剩余7条评论
1个回答

1
感谢KonstantinL的回答 我也遇到了这个问题并解决了它
我的gcc版本是11.1,etc/gdbinit只有一个gdbinit文件
我在/usr/share/gcc-11.3.0/python找到了libstdcxx库
参考KonstantinL的回答
将gdbinit修改为“sys.path.insert(0, '/usr/share/gcc-11.3.0/python')”
GDB可以正常运行
感谢KonstantinL的回答

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接