我正在尝试从源代码构建gdb,版本是11.1。 我已经配置了 GMP 包括路径,但是配置脚本仍然报错。
configure: error: GMP is missing or unusable
我复制了配置日志。
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
我的配置命令如下所示。
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
问题可能是什么?
您可以使用gdb的配置选项:
--with-libgmp-prefix="path to gmp"
从 GDB 的配置脚本来看,我认为问题在于 GDB 没有选择 --with-gmp-include 和 --with-gmp-lib 配置标志。这些标志在顶层配置脚本中处理,并通过环境提供给每个子组件(GDB、binutils、ld 等),看起来 GDB 没有选择这些标志。
最简单的前进方法是在配置时覆盖 CFLAGS 和 CXXFLAGS,例如:
configure CFLAGS="-I/gmp/include/path -L/gmp/lib/path" CXXFLAGS="-I/gmp/include/path -L/gmp/lib/path"
--- 稍后编辑---
虽然这个答案中的技术可行,但正确的答案是由姜达给出的。
我想分享我如何解决这个问题的经验。服务器上没有
sudo
。GMP
源(其证书现已过期)。我用过wget --no-check-certificate "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz"
。提取tar -xf gmp-6.2.1.tar.xz
;在其目录中 ./configure --prefix=$HOME/.local
、make
、make install
、make check
(安装程序礼貌地询问,出于某种原因 check
目标仅在 install
之后执行)。gdb
源进行的操作:在 gdb 目录 ./configure --prefix=$HOME/.local
、make
、make install
中。没有遇到 gmp
错误。
config.log
文件确实有助于更好地理解您的问题。
在您的情况下,您会在
gdb/config.log
下找到错误和生成它的命令:/.../gdb-x.y/gdb/configure
。如果您转到该文件,您会看到它需要 --with-libgmp-prefix
和 --with-mpfr-prefix
标志。这是一个已知的 gdb 特性。
您应该将这些标志与
--with-gmp
、--with-mpfr
等标志一起传递到顶级配置,正如姜达建议的那样。然而,我的实际构建仍然失败:
ld: can't map file, errno=22 file '/opt/homebrew/Cellar/mpfr/4.2.0-p12' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
如果发生这种情况,请检查
your_build_directory/gdb
下的 Makefile,特别是 LIBGMP
和 LIBMPFR
已解决的问题。对我来说,它们被自动配置为指向目录而不是实际的 lib 文件,所以我必须更改:
LIBGMP=/opt/homebrew/Cellar/gmp/6.2.1_1
LIBMPFR=/opt/homebrew/Cellar/mpfr/4.2.0-p12
到
LIBGMP=/opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmp.a
LIBMPFR=/opt/homebrew/Cellar/mpfr/4.2.0-p12/lib/libmpfr.a
之后
make all-gdb
终于成功了。