How do I link libxml2 with zlib1 on Windows?

*爱你&永不变心* 提交于 2019-12-08 06:24:15

问题


I need to compile libxml2 32-bit and 64-bit binaries for my TeamSpeak 3 plugin because I could not find a dll/lib 64-bit download. When I use my compiled libxml2.dll as a dependency in a command prompt application, it works just fine. However, when I try to use it as a dependency in TeamSpeak 3, the program immediately crashes on launch. Specifically it crashes on this line:

https://github.com/NobleUplift/TeamSpeak3WebsitePreview/blob/master/ts3websitepreview/plugin.c#L148

This is my batch script for compiling libxml2 on Windows:

@ECHO OFF
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
CD libxml2-2.9.4\win32
nmake clean
cscript configure.js compiler=msvc zlib=true prefix=D:\Repos\libxml2\release include=D:\Repos\libxml2\dll\include lib=D:\Repos\libxml2\dll\bin debug=yes
nmake
nmake install
cd ../..

The downloaded libxml2.dll on the left works. Compiled libxml2.dll is on the right. I've tried using the zlib flag, and I put my zlib headers in the include directory and the dll/lib in the lib directory, but I can't get it to link in the DLL.


回答1:


Well, I dunno whats wrong with yours, but here's how we compile the release version:

set TARGET_DIR=.\release_vc100
cscript configure.js compiler=msvc cruntime=/MD debug=no iconv=no legacy=no vcmanifest=no prefix=%TARGET_DIR% || exit /B 1
nmake /f Makefile.msvc clean || exit /B 1
nmake /f Makefile.msvc MSVC_VERSION=vc100 || exit /B 1
nmake /f Makefile.msvc install || exit /B 1

I guess you don't want iconv=no, but I'll note I explicitly specify /MD for the dynamic link release msvcrt and debug=no as well as passing MSVC_VERSION=vc100 to the make step.

I also note you pass zlib=truewhen the options seem to take yes|no - and I do think 'true' will not interpeted as 1, but as 0. (!= yes)

Looking at your depwalker output again, I somehow suspect your missing MSVC_VERSION switch may actuall be a problem, because depwalker lists a missing LIBiconv.dll and that naming scheme (LIB prefix for dynamic object) is a *nix thing as far as I understand this.)

As for your erro line -- dll load failed -- both depwalker screenshots show missing dependency DLL files:

  • Left side: iconv.dll and zlib1.dll are muissing

  • Right side: LIBiconv.dll is missing. (But I think there is no libiconv.dll on Windows, so there must be some wrong linker settings (??).


I also pass the makefile explicitly, but that may just be a leftover from a prior version where we tried some customized makefiles.

Side note: Debug version as:

cscript configure.js compiler=msvc cruntime=/MDd debug=yes iconv=no legacy=no vcmanifest=no prefix=%TARGET_DIR% || exit /B 1


来源:https://stackoverflow.com/questions/40568174/how-do-i-link-libxml2-with-zlib1-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!