You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下使用MINGW64编译gettext遇未定义引用错误求助

手动编译gettext 0.22.3时的链接错误问题

我想要使用gettext API解析po文件,手动编译gettext过程中出现以下错误:

Making all in adhoc-tests
make[5]: Enter directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3/libtextstyle/adhoc-tests”
  CC       hello.o
  CCLD     hello.exe
libtool: warning: library '/home/test/gettext-tools-windows/build/stage/usr/local/lib/libiconv.la' was moved.
libtool: warning: library '/home/test/gettext-tools-windows/build/stage/usr/local/lib/libiconv.la' was moved.
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0x98): undefined reference to `__imp_color_test_mode'
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0xa8): undefined reference to `__imp_color_mode'
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0xcc): undefined reference to `__imp_style_file_name'
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0x1c1): undefined reference to `__imp_style_file_name'
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0x21a): undefined reference to `__imp_style_file_name'
C:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: hello.o:hello.c:(.text.startup+0x250): undefined reference to `__imp_style_file_name'
collect2.exe: error: ld returned 1 exit status
make[5]: *** [Makefile:1777:hello.exe] Error 1
make[5]: Leave directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3/libtextstyle/adhoc-tests”
make[4]: *** [Makefile:1992:all-recursive] Error 1
make[4]: Leave directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3/libtextstyle”
make[3]: *** [Makefile:1920:all] Error 2
make[3]: Leave directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3/libtextstyle”
make[2]: *** [Makefile:406:all-recursive] Error 1
make[2]: Leave directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3”
make[1]: *** [Makefile:362:all] Error 2
make[1]: Leave directory“/home/test/gettext-tools-windows/build/compile/gettext-0.22.3”
make: *** [Makefile:100:/home/test/gettext-tools-windows/build/compile/GETTEXT.built] Error 2

解决方法

  • 修正libtextstyle库链接:未定义的符号均属于libtextstyle库,打开libtextstyle/adhoc-tests/Makefile,修改hello.exe的链接规则,确保添加$(top_builddir)/libtextstyle.la或对应静态库的引用。
  • 修复libiconv路径:根据警告提示,libiconv.la路径已变动,重新配置时指定正确的libiconv安装路径:
    ./configure --with-libiconv-prefix=/正确的libiconv安装路径
    
  • 跳过测试编译:如果不需要测试程序,配置时添加参数关闭测试:
    ./configure --disable-tests
    
    或直接执行安装命令跳过错误:
    make install -k
    
  • 重新生成配置:删除编译目录下的所有文件,重新运行configure生成正确的Makefile:
    rm -rf build/compile/gettext-0.22.3/*
    ../configure [你的编译参数]
    make
    

内容的提问来源于stack exchange,提问作者xxa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 23:42:52