I have MSYS2 and MinGW64 installed under Windows 7.
gdb reports "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
I have found several links:
Import Error: No module name libstdcxx
ImportError: No module named 'libstdcxx' while debuging project with ncurses
How to enable gdb pretty printing for C++ STL objects in Eclipse CDT?
https://askubuntu.com/questions/345873/gdb-crashes-with-importerror-no-module-named-libstdcxx-v6-printers
https://github.com/Alexpux/MINGW-packages/issues/383
but none of them helps.
Update:
There are 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
Thanks for KonstantinL's answer I also encountered this problem and solved it
my gcc version is 11.1 ,There is only one gdbinit at etc/gdbinit
And I found the libstdcxx library at /usr/share/gcc-11.3.0/python
Refer to KonstantinL's answer
Modify the gdbinit as “sys.path.insert(0, '/usr/share/gcc-11.3.0/python')”
GDB can run normally
Thanks for KonstantinL's answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With