使用libtool构建dll时获取exe

时间:2015-02-26 13:15:46

标签: c++ dll mingw ld libtool

我正在尝试使用MinGW在Windows上编译.dll项目.exe。一切都没问题,除了一点:输出是.dll文件 - 而不是*** 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.

以下是libtool给我的通知:

-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. 期间弹出此警告:

{{1}}

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

您可以使用包含以下内容的.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