Linker Can';在Mingw中不编译共享库,编译器不';看不到系统库

Linker Can';在Mingw中不编译共享库,编译器不';看不到系统库,linker,mingw,libtool,Linker,Mingw,Libtool,我在Windows中使用MinGW(msys2)编译开源库时收到此警告 *** Warning: linker path does not have real file for library -lcrypt32. *** I have the capability to make that library automatically link in when *** you link to this library. But I can only do this if you have a

我在Windows中使用MinGW(msys2)编译开源库时收到此警告

*** Warning: linker path does not have real file for library -lcrypt32.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libcrypt32 and none of the candidates passed a file format test
*** using a file magic. Last file checked: C:/msys64/mingw32/i686-w64-mingw32/lib/libcrypt32.a
由于这个错误,我无法编译共享库,只能静态编译


文件
C:/msys64/mingw32/i686-w64-mingw32/lib/libcrypt32。a
存在,并且通常链接到同一环境下的其他库中

如果无法找到合适的库候选链接,则
libtool
将显示警告消息。在我的例子中,问题的根源是我的区域设置。已安装的
libtool
使用
objdump
的输出来检查找到的候选项是否为导入库,并期望以英语输出:

    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|coff-arm|coff-arm64|coff-i386|coff-x86-64)' >/dev/null; then

因此,在创建库之前将语言设置为英语解决了我的问题:
LANG=en_US.UTF-8 make
您试图构建的开源项目可能有一个旧的
configure
脚本,该脚本生成的
libtool
在Windows中还不能正常工作(或者Windows 64位,以防这正是您构建的目的)

运行
autoreconf
是确保您拥有更新的
configure
脚本的一种可能的解决方案。某些源代码还包括某种引导脚本

我还见过其他情况,其中由于链接器标志
-Wl,-no undefined
丢失,生成共享库(DLL)失败。有时可以通过运行以下命令来修复此问题:

sed -i.bak -e "s/\(allow_undefined=\)yes/\1no/" libtool

缺少
-没有未定义的
标志会在共享库编译期间导致错误,而不是warning@AlexanderUshakov链接共享对象时,链接器将在没有该标志的情况下失败,但autoconf/make将显示警告并仅生成静态库