Search code examples
gdbgmp

gmp is missing while configuring building gdb from source


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?


Solution

  • 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.