I'm trying to use gdb on ubuntu 12.04, but every time the program crashes with the following error
gdb: symbol lookup error: gdb: undefined symbol: PyUnicodeUCS4_FromEncodedObject
Looks something Python related, but I do not know what to do...
Again I will answer myself to my own question for the sake of others:
the error was tied to an incorrect PATH, by typing
which python
the command returned a path which was NOT the system default python path.
Gdb looks for the default python installation so, in my case, was enough to comment out a source path command in my .bashrc which was overriding the /usr/bin/python path in PATH.
And just like Mutewinter I add my own answer to problem:
A custom specification of LD_LIBRARY_PATH
, needed for the project I was supposed to debug, caused the problem. If LD_LIBRARY_PATH
contains another version of libpython
, gdb may link in the wrong version causing the symbol error.
You can check which version of libpython
gdb will use using the following command:
ldd /usr/bin/gdb
Kind regards, Erik
Your can download python2.6 source code such as
https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tar.bz2
https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tar.bz2.asc
extract and install
gpg --verify Python-2.6.8.tar.bz2.asc
tar -xvf Python-2.6.8.tar.bz2
cd Python-2.6.8
./configure --enable-shared --enable-ipv6 --enable-unicode=ucs4 --with-system-ffi --with-threads
make -j5
make install