C++ 对'libintl_gettext';的未定义引用;使用MinGW/MSYS和CMake

C++ 对'libintl_gettext';的未定义引用;使用MinGW/MSYS和CMake,c++,windows,gettext,mingw32,msys,C++,Windows,Gettext,Mingw32,Msys,我试图向C++项目添加GETEXT。它在Linux下编译并运行良好,但在Windows7 64位中,我发现MinGW32存在链接器错误。我正在使用cmake-G“MSYS Makefiles”进行编译。,因为MinGW不适用于soe模糊的原因。我也试过忍者 在CMakeLists.txt中,我有 find_package(Gettext REQUIRED include_directories(${GETTEXT_INCLUDE_DIR}) if (INTL_FOUND) find_pa

我试图向C++项目添加GETEXT。它在Linux下编译并运行良好,但在Windows7 64位中,我发现MinGW32存在链接器错误。我正在使用
cmake-G“MSYS Makefiles”进行编译。
,因为MinGW不适用于soe模糊的原因。我也试过忍者

CMakeLists.txt
中,我有

find_package(Gettext REQUIRED
include_directories(${GETTEXT_INCLUDE_DIR})
if (INTL_FOUND)
    find_package(INTL REQUIRED)
    include_directories(${INTL_INCLUDE_DIR})
endif()
被发现为

 GETTEXT_INCLUDE_DIR = C:/MinGW/msys/1.0/local/include
项目编译时没有问题,但在链接阶段,我发现以下错误:

<source file location> undefined reference to `libintl_gettext'
<source file location> undefined reference to `libintl_setlocale'
<source file location> undefined reference to `libintl_textdomain'
然后我试着

SET(GCC_COVERAGE_COMPILE_FLAGS "-s -O2 -lintl -liconv -LC:/MinGW/msys/1.0/local/lib -IC:/MinGW/msys/1.0/local/include")
SET(GCC_COVERAGE_LINK_FLAGS    "-lintl -liconv -LC:/MinGW/msys/1.0/local/lib -IC:/MinGW/msys/1.0/local/include")

这也不起作用。

我正在使用Win builds,我遇到了类似的问题。 我只是想用gettext构建一个Hello World程序

据我所知,这应该有效,但不能:

gcc -lintl.dll -D__USE_MINGW_ANSI_STDIO -Wall -Wextra -Werror -std=gnu99 -o testGettex.exe testGettex.c
输出为:

C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x1a): undefined reference to `libintl_setlocale'
C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x2b): undefined reference to `libintl_setlocale'
C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x3e): undefined reference to `libintl_bindtextdomain'
C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x4a): undefined reference to `libintl_textdomain'
C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x56): undefined reference to `libintl_gettext'
C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o:testGettex.c:(.text+0x5e): undefined reference to `__printf__'
d:/prog/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Julien\AppData\Local\Temp\ccAvCaR2.o: bad reloc address 0x0 in section `.pdata'
d:/prog/win-builds/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
因此,我尝试使用
.dll
直接链接,而不是使用
.dll.a
,我可以使用以下命令进行构建:

gcc -D__USE_MINGW_ANSI_STDIO -Wall -Wextra -Werror -std=gnu99 -o testGettex.exe D:\Prog\Win-builds\bin\libintl-8.dll testGettex.c
但是,我不知道您如何告诉CMake直接链接到
.dll
。。。也许最好的办法是找到MinGW的bug跟踪器,并向他们解释文件
libintl.dll.a
的问题

编辑:我刚刚阅读了您提供的链接,我看到了另一个同样有效的解决方案,将两个-l选项移动到命令末尾

gcc -D__USE_MINGW_ANSI_STDIO -Wall -Wextra -Werror -std=gnu99 -o testGettex.exe testGettex.c -lintl.dll -liconv
也许有一种方法可以告诉CMake将这两个选项移到行的末尾

gcc -D__USE_MINGW_ANSI_STDIO -Wall -Wextra -Werror -std=gnu99 -o testGettex.exe testGettex.c -lintl.dll -liconv