[Qemu][Cross Compile for windows][Mingw] 启用curses时找不到langinfo.h

问题描述

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

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

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

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

/qemu/bin/ndebug/x86_64-w64-mingw32# sys:1: 警告: g_file_test: 断言 'filename != NULL' 失败 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-negative-value -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_SOURCE6=186Iusr_60 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 不需要那个标头(它的配置脚本处理它的缺失)。

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

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

    [PULL 2/9] curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw
    Gerd Hoffmann Wed,14 Oct 2020 01:27:01 -0700
    From: Yonggang Luo <luoyongg...@gmail.com>
    msys2/mingw lacks the POSIX-required langinfo.h.
    
    gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw 
    -lgnurx -ltre -lintl -liconv
    test.c:4:10: fatal error: langinfo.h: No such file or directory
        4 | #include <langinfo.h>
          |          ^~~~~~~~~~~~
    compilation terminated.
    
    So we using g_get_codeset instead of nl_langinfo(CODESET)