【问题标题】:[Qemu][Cross Compile for windows][Mingw] langinfo.h is not found when enable curses[Qemu][Cross Compile for windows][Mingw] 启用curses时找不到langinfo.h
【发布时间】:2023-10-07 20:18:01
【问题描述】:

目前我们正在尝试在 Ubuntu 机器上为 Xilinx 设备编译 Qemu,并且我们按照 link 使用 Mingw64 为 Windows 交叉编译它。

当 Curses 功能被禁用时 Qemu 编译成功,但是当我们通过添加 --enable-curses 启用 Curses 功能时它会失败并出现错误

Blockquote 错误:用户请求的功能 curses 配置无法找到它。安装 ncurses 开发

当我们进行更多调试时,我们发现 configure 正在尝试编译 curses,然后才允许使用以下命令进行 make:

/qemu/bin/ndebug/x86_64-w64-mingw32# sys:1: 警告:g_file_test: assertion 'filename != NULL' failed S=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -Wold-style-declaration -Wold-样式定义 -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-missing-include-dirs - Wno-shift-负值 -Wno-psabi -fstack-protector-strong -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/x86_64-w64-mingw32/sys-root/ mingw/include/p11-kit-1 -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/ x86_64-w64-mingw32/sys-root/mingw/include/libpng16 -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -I/usr/x86_64- w64-mingw32/sys-root/mingw/include -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -no-pie -m64 -fstack-protector-strong -L/usr/x86_64- w64-mingw32/sys-root/ mingw/lib -Wl,--enable-auto-import -lncursesw

,这会失败并出现以下错误:

config-temp/qemu-conf.c:4:10:致命错误:langinfo.h:没有这样的文件或目录

根据gnu langinfo.h 在mingw 上丢失。

所以, 有谁知道解决这个问题的其他方法? 我们应该使用 ncurse 以外的软件包吗?(比如 -> pcurses,...) 如何将 langinfo.h 包含到 mingw 中? (我搜索了它但没有成功,我试图将所有这些库复制到 mingw 包含路径,但肯定会失败)。

非常感谢您的提前支持,祝大家新年快乐

【问题讨论】:

  • ncurses 不需要该标头(它的配置脚本会处理它的缺失)。
  • 非常感谢@ThomasDickey 的支持,我检查了qemu 的curses,并且在curses.c 中它包含langinfo.h,您可以在以下路径中找到使用过的curses:github.com/Xilinx/qemu/blob/master/ui/curses.c跨度>
  • 这是 QEMU 的一部分(不是 ncurses 的一部分)。可能是为了CODESET 查找。
  • aaah,好的,非常感谢您的澄清:D,所以 ncurses 库不包括 langinfo.h 但 qemu 包含它用于 qemu 诅咒,你(@ThomasDickey)知道如何包含mingw 中的 langinfo.h 库,这可能吗?
  • 好的,非常感谢@ThomasDickey 的支持,我通过将 nl_langinfo 替换为 g_get_codeset() 应用了您刚刚发送的链接上的解决方法,它最终正确构建:D,再次感谢您的支持

标签: mingw qemu ncurses mingw-w64 curses


【解决方案1】:

对 cme​​ts 的总结:

  • ncurses 不需要该标头(它的配置脚本会处理它的缺失)。

  • 引用的 curses.c 源文件是 QEMU 的一部分(不是 ncurses 的一部分)。可能是为了CODESET 查找。

  • QEMU 的配置脚本显然没有检查这一点,但在 QEMU 的开发邮件列表October 2020 中指出了它的缺失(和建议的解决方案):

[PULL 2/9] 诅咒:修复编译器错误,抱怨在 msys2/mingw 上没有 langinfo.h Gerd Hoffmann 2020 年 10 月 14 日,星期三 01:27:01 -0700 From: 罗永刚 msys2/mingw 缺少 POSIX 所需的 langinfo.h。 gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv test.c:4:10:致命错误:langinfo.h:没有这样的文件或目录 4 | #include | ^~~~~~~~~~~~ 编译终止。 所以我们使用 g_get_codeset 而不是 nl_langinfo(CODESET)

【讨论】: