Mai*_*aly 1 mingw makefile msys openfst c++17
我正在尝试使用 MINGW64 和 Msys 在 windows10 上构建和安装OpenFst库,但在使用 make 构建过程中出现以下错误。我首先使用这个命令:
./configure --enable-grm --enable-far --enable-ngram-fsts MAKE="mingw32-make"
Run Code Online (Sandbox Code Playgroud)
此命令的一些检查结果不会生成:
checking whether we are cross compiling... no
checking for sysroot... no
checking for a working dd... ./configure: line 7016: cmp: command not found
./configure: line 7016: cmp: command not found
checking for mt... no
checking if : is a manifest tool... no
checking for unistd.h... no
checking if gcc supports -fno-rtti -fno-exceptions... ./configure: line 8930: diff: command `not found`
checking whether to build static libraries... no
Run Code Online (Sandbox Code Playgroud)
其他检查结果都正常,是的。然后我使用了 make 命令:
mingw32-make
Run Code Online (Sandbox Code Playgroud)
它适用于某些文件,然后因该错误而终止:
libtool: error: can't build x86_64-w64-mingw32 shared library unless -no-undefined is
specified
Run Code Online (Sandbox Code Playgroud)
这是我第一次使用 MinGW 进行构建。因此,我不知道该错误意味着什么,也不知道负责该错误的配置是否会进行“否”检查。
这个是正常的。
当仍有未解析的符号时,MinGW 不允许构建共享库 (DLL),因为在 Windows 上,从 DLL 引用的每个符号都必须指向存在的内容。在其他平台上,这并不总是需要的。
所以你应该在链接时传递 to -Wl,-no-undefined。gcc
对于使用 autoconf 的项目,configure如果它是足够新的 autoconf 版本,通常已经完成了。否则您可能需要添加LDFLAGS="-Wl,-no-undefined"到该configure行。如果这没有帮助,您可以尝试在libtool生成的文件中更改它configure。
因此,您可以在 MSYS/MSYS2 shell 中尝试:
./configure LDFLAGS="-Wl,-no-undefined"
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,你也可以尝试这个(在configure命令之后和运行之前make):
sed -i.bak -e "s/\(allow_undefined=\)yes/\1no/" libtool
Run Code Online (Sandbox Code Playgroud)
其他构建工具(如 cmake、meson 或 scons)已经知道如何构建 Windows DLL,无需特殊处理。