5

I am trying to build gdb from source, which version is 11.1. I have configured the GMP including path, but the configure script still report an error.

configure: error: GMP is missing or unusable

I copied the config log.

configure:10433: checking for libgmp
configure:10453: gcc -o conftest -g -O2      conftest.c -lncurses -lm -ldl  -lgmp >&5
conftest.c:53:17: fatal error: gmp.h: No such file or directory

My configure command is something like below.

configure --prefix=/home/xxx/ins/gdb_11 --with-gmp-include=/home/xxx/ins/gmp-6.2.1/include --with-gmp-lib=/home/xxx/ins/gmp-6.2.1/lib

What might the problem be?

halfer
  • 19,824
  • 17
  • 99
  • 186
user3236879
  • 511
  • 2
  • 7
  • 17

4 Answers4

9

Make sure you have libgmp-dev installed

My OS is ubuntu 20.04

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libgmp-dev
wget http://ftp.gnu.org/gnu/gdb/gdb-11.2.tar.gz
tar -xvzf gdb-11.2.tar.gz
./configure
make
sudo make install

Once you installed GDB, you can print GDB version to test whether it is installed correctly.
gdb --version img

hiifong
  • 196
  • 1
  • 2
4

You can use gdb's configure option:

  --with-libgmp-prefix="path to gmp"
ouflak
  • 2,458
  • 10
  • 44
  • 49
jiang da
  • 41
  • 2
3

From looking at GDB's configure script, I think the problem is that GDB is not picking up the --with-gmp-include and --with-gmp-lib configure flags. These flags are handled in the toplevel configure script and made available to each sub-component (GDB, binutils, ld, etc) through the environment, and it looks like GDB doesn't pick these up.

The easiest way to move forward will be to override CFLAGS and CXXFLAGS at configure time, like:

configure CFLAGS="-I/gmp/include/path -L/gmp/lib/path" CXXFLAGS="-I/gmp/include/path -L/gmp/lib/path"

--- Later Edit ---

Though the technique in this answer will work, the correct answer is given by jiang da.

Andrew
  • 3,770
  • 15
  • 22
2

I'd like to share my experience how I solved this. No sudo on the server.
First, download GMP sources from the site (its certificate is expired now). I used wget --no-check-certificate "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz". To extract tar -xf gmp-6.2.1.tar.xz; in its directory ./configure --prefix=$HOME/.local, make, make install, make check (installer politely asked, for some reason check target executed only after install).
Last operations with extracted gdb sources: in gdb directory ./configure --prefix=$HOME/.local, make, make install. No gmp errors encountered.

amordo
  • 449
  • 5
  • 15