配置从源构建 gdb 时缺少 gmp

问题描述 投票:0回答:5

我正在尝试从源代码构建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 gmp
5个回答
9
投票

确保您已安装 libgmp-dev

我的操作系统是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

安装GDB后,可以打印GDB版本来测试是否安装正确。

gdb --version
img


4
投票

您可以使用gdb的配置选项:

  --with-libgmp-prefix="path to gmp"

3
投票

从 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"

--- 稍后编辑---

虽然这个答案中的技术可行,但正确的答案是由姜达给出的。


2
投票

我想分享我如何解决这个问题的经验。服务器上没有

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
错误。


0
投票

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
终于成功了。

© www.soinside.com 2019 - 2024. All rights reserved.