【问题标题】:Getting exe when building dll using libtool使用 libtool 构建 dll 时获取 exe
【发布时间】:2015-02-26 13:15:46
【问题描述】:

我正在尝试使用 MinGW 在 Windows 上编译 this 项目的 .dll。一切正常,除了一点:输出是 .exe 文件 - 不是 .dll

这是 libtool 给我的通知:

*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.

好吧,我在项目选项 -no-undefined 中没有找到任何地方,这就是为什么我想知道应该修复哪些符号(以及如何修复??)才能得到需要 .dll

也许链接器有一些问题?我不知道在哪里更改($LIBRARY_PATH = /c/mingw 已经),这就是为什么在make 期间弹出此警告:

*** Warning: linker path does not have real file for library -lz.
*** 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 libz and none of the candidates passed a file format test
*** using a file magic. Last file checked: c:/Strawberry/c/bin/../lib/gcc/x86_64
-w64-mingw32/4.8.3/../../..//libz.a
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

【问题讨论】:

    标签: c++ dll mingw ld libtool


    【解决方案1】:

    看起来您的程序需要 zlib,但 c:/Strawberry/c/bin/../lib/gcc/x86_64 -w64-mingw32/4.8.3/../../..//libz.a 无效(不同的目标架构 - x86 与 x86_64?)。你需要得到一个真正的zlib,为相同的架构编译并将你的程序指向它。

    【讨论】:

      【解决方案2】:

      您可以使用具有以下内容的 .cmd 文件

      ::source code file path
      set src_path=source.cpp
      
      ::output file path
      
      set bin_path=yourlib.dll
      
      ::library you need
      
      set libs=-lmingw32 -lkernel32 -lshell32 -luser32 -lwsock32 -lws2_32 -lole32 -loleaut32
      
      ::windows subsystem
      
      set sub_sys=-mwindows
      
      ::cpp version used by g++
      
      set cpp_ver=-std=c++1y
      
      ::jump to g++ path
      
      cd "%your_mingw32_folder_path%\bin\"
      
      ::run g++ with args
      
      g++.exe "%src_path%" -o "%bin_path%" -Wall -W -w -static %sub_sys% %libs% %cpp_ver%
      
      
      pause
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多