14

The thing is, I want to have python support in my GDB installation. When I ran

./configure --with-python 

with

make

in the GDB source file directory, however, the "make" exited with the following information:

checking whether to use python... yes
checking for python... (cached) /home/tools/tools/../bin/64//python
checking for python2.7... no
configure: error: python is missing or unusable"

Note that the returned information possible indicates that the "make" program is trying to find a python intallation in "/home/tools/tools/../bin/64//python" directory, which, however is not the default python installation of my account. I've set the $PATH variable to make the "python" command pointing to a python installation of my own, which resides under home directory.

Why is this? Can anyone help? A thousand thanks.

PS. There's one thing I'm not sure, since I only want to have some script automatically run in the ".gdbinit" file, which seems like some python script. Does supporting this script equal to making GDB able to debug python script??

3
  • 4
    If configure isn't picking out your desired version of python, try ./configure --with-python=/path/to/python-executable. That executable is going to be asked by configure to run gdb/python/python-config.py with various arguments to produce info about the python implementation, such as the location of libpython. Commented Nov 13, 2014 at 17:09
  • thanks. your method works. :) Commented Dec 11, 2014 at 6:50
  • @MarkPlotnick: you should consider adding your comment here as an answer down below. Commented Jul 3, 2018 at 16:57

5 Answers 5

11

I had this same problem. I am using Python 2.7.10 - Anaconda 2.3.0 (installed in a non-standard location), and GDB-7.11. It turns out that within gdb-7.11/ there are multiple autoconfigs. When I inspected gdb-7.11/gdb/config.cache, there was an error because it could not find python2.7 library. So the solution is to export LDFLAGS, when running the top level autoconfig in gdb-7.11 otherwise the autoconfig in gdb-7.11/gdb will not know where to find the python2.7 library.

E.G.

 make distclean
 cd gdb/
 make distclean
 cd ../
 export LDFLAGS=-L/path/to/nonstandard/python/lib/; ./configure --prefix=/path/to/home/directory/gdb-7.11/ --with-python

NOTE : In this situation, it is best to clean both the top level and the gdb configures. Cleaning the top level configure will not clean the gdb/ configure. This gave me some grief.

Sign up to request clarification or add additional context in comments.

1 Comment

That's not a solution in most case currently because of this bug. See the link below. stackoverflow.com/questions/49850815/…
10

Install python libraries with,

sudo apt-get install python2.7-dev

Now try,

./configure --with-python
make

Comments

4

I assume your python2.7 binary is installed under /usr/bin

then you can try ./configure --with-python=python2.7 then make and gdb makefile will search for the python binary to get python header and lib to complete the compilation

Comments

2

This error usually happens when python is not installed in a standard location.

If you are building python from source, then configure and build it as:

./configure --enable-shared --prefix=$HOME/local LDFLAGS="-Wl,--rpath=$HOME/local/lib"
make install

After python has been built (change $HOME/local to where you prefer), it is time to configure and build gdb (tested with GDB 7.10):

export LDFLAGS="-Wl,-rpath,$HOME/local/lib -L$HOME/local/lib"
./configure --with-python=$HOME/local/bin/ --prefix=$HOME/local
make install

1 Comment

In the export command, is there a typo in -rpath,$HOME/local/lib. Shouldn't it be --rpath=$HOME/local/lib instead?
2

This thread is very old and I tried to follow its guidelines for building gdb 13.1 with python support but failed thereupon.

The key for me in succeeding, however, was to actually reference the python3 binary (3.7.7 in my case) instead of python 2 (2.7.15):

./configure --prefix=/work/usr --with-python=/work/usr/bin/python3

This is supported by this statement from sourceware.org/gdb's documentation (https://www.sourceware.org/gdb/current/onlinedocs/gdb.html/Configure-Options.html):

The oldest version of Python supported by GDB is 3.0.1.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.