Ubuntu下使用gdb调试C++程序,提示:ImportError: No module named ‘libstdcxx’。貌似CentOS没有这样的问题。

这是我的开发环境:

theone@ubuntu:~$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

theone@ubuntu:~$ gdb --version
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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 "i686-linux-gnu".
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".
theone@ubuntu:~$ python -V
Python 2.7.6

解决方案:
在自己的用户根目录下面新建.gdbinit文件
cd ~
vim .gdbinit
然后复制如下代码到.gdbinit文件:

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

即在系统的path中添加gcc自带的python目录即可。