Arch Linux下编译Busybox提示找不到ncurses头文件(已安装ncurses)
问题场景
在Docker的Arch Linux x86_64镜像中编译Busybox,已安装bzip2 git make gcc ncurses flex bison bc cpio libelf openssl等依赖,但执行cd busybox && make menuconfig时,仍弹出如下错误:
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.*** Install ncurses (ncurses-devel) and try again.
make[2]: *** [/home/sysmount/busybox/scripts/kconfig/lxdialog/Makefile:15: scripts/kconfig/lxdialog/dochecklxdialog] Error 1
make[1]: *** [/home/sysmount/busybox/scripts/kconfig/Makefile:14: menuconfig] Error 2
make: *** [Makefile:444: menuconfig] Error 2
Arch Linux的ncurses包已包含头文件,此错误属于路径检测异常。
解决方法
方法1:指定ncurses头文件路径编译
直接在编译命令中添加CFLAGS参数,指定ncurses头文件的位置:
CFLAGS="-I/usr/include/ncurses" make menuconfig
方法2:创建头文件软链接
将ncurses子目录下的头文件链接到系统默认头文件目录,让编译器直接找到:
ln -s /usr/include/ncurses/*.h /usr/include/ make menuconfig
方法3:安装ncurses静态库并重新编译
安装ncurses-static包,解决可能的动态库链接问题:
pacman -Syu ncurses-static make menuconfig
方法4:安装pkg-config辅助路径检测
Busybox的配置脚本可能依赖pkg-config来查找库文件,安装后再尝试编译:
pacman -Syu pkg-config make menuconfig
内容的提问来源于stack exchange,提问作者Suryansh

