编译 binutils-gdb 找不到 ncurses

compilation of binutils-gdb can't find ncurses

我正在尝试根据本教程为 i686-elf 目标编译 binutils:

我刚刚添加了 --enable-tui 选项,这样我就得到了 gdb 的支持。

我做了以下事情:

# get sources
git clone git://sourceware.org/git/binutils-gdb.git

# store settings
export PREFIX="`pwd`/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

# create build folder
mkdir build-binutils
cd build-binutils

# run configure
../binutils-gdb/configure -target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror --enable-tui

# make
make

这会运行一段时间并因以下错误而终止:

checking for library containing socketpair... (cached) none required
checking for ld used by GCC... (cached) ld
checking if the linker (ld) is GNU ld... (cached) yes
checking for shared library run path origin... (cached) done
checking for iconv... (cached) yes
checking for iconv declaration... (cached) 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for library containing waddstr... (cached) no
configure: error: no enhanced curses library found; disable TUI
make[1]: *** [Makefile:11329: configure-gdb] Error 1
make[1]: Leaving directory '/home/noexpandtab/dev/build-binutils'
make: *** [Makefile:853: all] Error 2

对我来说,似乎找不到 ncurses 库。

我有一个 Debian 10 运行 并安装了以下附加软件包:

我必须安装额外的软件包吗?还是我缺少配置脚本的一些选项?

你正在交叉编译到一个不同的体系结构 (i686-elf) 而不是你正在使用的任何体系结构 运行——$TARGET 在问题中提到。 gdb 必须与为该体系结构构建的库链接。

Debian 提供ncurses packages 运行 当前架构,但没有提供适合交叉编译应用程序的软件包。所以你可以自己做。

当交叉编译 ncurses 时,你必须记住它的一部分 builds/runs 在 current 架构上(生成用于编译的源文件由交叉编译器)。这在环境中定义为 $BUILD_CC(而不是 $CC),正如您在阅读概述过程的 mingw cross-compiling. There's a section in the INSTALL 文件(在 ncurses 源中)的脚本时可能会看到的那样。

没有教程(无论如何这里都是题外话),但其他人已经阅读了说明并交叉编译了 ncurses,最近 bug report.

证明了这一点

我重试了整个编译,突然就成功了!我测试了一下,我想我发现了我的错误:我执行了 configure 而没有 --enable-tui,其中 make 有效。然后我在同一个文件夹中执行 configure--enable-tui 而没有清理它。清理或 运行 在新文件夹中编译后。

感谢发帖删除opt/cross内容的一位用户。 (评论本身已经不知何故被删除了。)这不是解决方案,但引导我朝着正确的方向前进。

TL;DR: 再次使用不同参数清理 运行 configure 之前的构建文件夹。