13

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??

waytofall
  • 383
  • 1
  • 3
  • 13
  • 3
    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. – Mark Plotnick Nov 13 '14 at 17:09
  • thanks. your method works. :) – waytofall Dec 11 '14 at 06:50
  • @MarkPlotnick: you should consider adding your comment here as an answer down below. – jefe2000 Jul 03 '18 at 16:57

5 Answers5

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.

irritable_phd_syndrome
  • 4,631
  • 3
  • 32
  • 60
  • That's not a solution in most case currently because of this bug. See the link below. https://stackoverflow.com/questions/49850815/how-to-build-gdb-under-pyenv-environment – fx-kirin Apr 18 '18 at 11:08
10

Install python libraries with,

sudo apt-get install python2.7-dev

Now try,

./configure --with-python
make
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

evandrix
  • 6,041
  • 4
  • 27
  • 38
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
A.L.
  • 1,133
  • 1
  • 12
  • 19
  • In the `export` command, is there a typo in `-rpath,$HOME/local/lib`. Shouldn't it be `--rpath=$HOME/local/lib` instead? – urmish Dec 06 '19 at 19:01
0

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
Else Ifthen
  • 117
  • 4