1

I successfully compiled libxml2 on Windows after compiling libiconv:

http://www.codeproject.com/Articles/302012/How-to-Build-libiconv-with-Microsoft-Visual-Studio

And following this tutorial:

http://marlowa.blogspot.com/2013/07/how-to-build-libxml2-on-windows-using.html

And now I'm trying to generate a manifest file for libxml2.dll. How do I do this? I've Googled around and it says to create the manifest file in Visual Studio, but I'm compiling from the command line. This is the script I used to build it:

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

I get a "Module not found" exception on this line of my plugin, and I confirmed it was an issue with libxml2.dll because using a downloaded binary of the libxml2.dll, it works just fine.

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

Any and all help appreciated. I'm almost finished with this project that I've had bouncing around since 2011.

working libxml2.dll is on the left, broken libxml2 is on the right

libxml2.dll on the left works. Compiled libxml2.dll is on the right. It turns out the libxml2 being compiled doesn't have a zlib1 dependency, which might be the issue.

NobleUplift
  • 5,631
  • 8
  • 45
  • 87
  • There is no conceivable reason why you'd *need* a manifest file for libxml2. It was written in plain C and does not use COM, nothing needs to be doctored. – Hans Passant Oct 30 '16 at 10:30
  • @HansPassant Well, I have a downloaded binary for libxml2 (only reason I'm compiling on Windows is lack of a 64-bit binary download) and if I sub that one back into my Win32 build, my program works, but if I use the libxml2 that I compiled, the program instantly crashes. Would it matter that I'm trying to dynamically link the compiled libxml2.dll? – NobleUplift Oct 31 '16 at 14:28
  • You'll have to use a debugger instead of random guesses. – Hans Passant Oct 31 '16 at 14:31
  • @HansPassant It's not a random guess though; I'm just following the directions in Andrew Marlow's blog. The weird thing is I created a test project and ran the code as a console application, which runs just fine, but when I compile it to be run in my plugin, I get a "Module not found" exception [here](https://github.com/NobleUplift/TeamSpeak3WebsitePreview/blob/master/ts3websitepreview/plugin.c#L148). – NobleUplift Oct 31 '16 at 21:35
  • @HansPassant, I added a screenshot of dependency walker. Seems the libxml2 that I'm compiling doesn't have zlib1. I'll try to get that into the compilation and see if that fixes it. – NobleUplift Nov 05 '16 at 21:23

2 Answers2

1

After running cscript configure.js and before running nmake, edit the generated Makefile and add /MANIFEST to LDFLAGS.

nwellnhof
  • 32,319
  • 7
  • 89
  • 113
  • I'll try this when I get home. – NobleUplift Oct 31 '16 at 14:20
  • I added the `/MANIFEST` flag but I can't seem to find the generated manifest files. I have the folders `bin.msvc`, `int.a.dll.msvc`, `int.a.msvc`, `int.utils.msvc`, `VC10`, and `wince` in my `win32` directory, but no `.mf`/`.manifest`/`.xml` files. – NobleUplift Nov 05 '16 at 20:57
  • Disregard the above, I forgot to run an `nmake clean` before running `cscript` again. I have the manifest file and I'll try embedding now. Thanks! – NobleUplift Nov 05 '16 at 23:42
  • Nick, we have a `vcmanifest=yes|no` switch, so why add one manually? (see my answer) – Martin Ba Nov 23 '16 at 20:09
  • @MartinBa The `vcmanifest` switch only seems to run `mt.exe` if a manifest file is present. When I was testing with MSVC10, no manifest was created without the `/MANIFEST` option. But to be honest, I never worked with manifest files, so I have no idea what I'm talking about. – nwellnhof Nov 23 '16 at 23:44
  • @nwellnhof - Thanks. I checked the [VS docs for `/MANIFEST`](https://msdn.microsoft.com/en-us/library/f2c0w594.aspx) and all versions seem to agree that `/MANIFEST` (means yes) is the default. Whatever. (Side note: Do you somewhat agree with my answer below?) – Martin Ba Nov 24 '16 at 08:27
  • @MartinBa I read the docs but for some reason MSVC10 didn't create a manifest without `/MANIFEST`. Maybe because it's unnecessary? I really don't know. – nwellnhof Nov 24 '16 at 13:16
1

(a) the current (2.9.4) configure script has a vcmanifest=yes|no option that does work, as far as I can tell.

(b) You do not need one. The manifest (as noted in the blog you link to) is required for vc80 (VS 2005) and vc90 (VS2008) because in these studio version, the msvcrt was resolved via manifest / WinSxS.

In vc10 / Studio 2010 and above, the msvcrt is again installed in the Windows\System32 location, and you do not need the manifest to load the crt.

From your dep-walker screenshot, what you're actually missing is iconv.dll and zlib1.dll and these don't require manifests either, but are required unless you compile with iconv=no zlib=no (which may not be what you want).

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
  • I moved the zlib1 issue into [this question here](http://stackoverflow.com/questions/40568174/how-do-i-link-libxml2-with-zlib1-on-windows), but I'm using `zlib=yes` and it's not showing a zlib link in Dependency Walker. – NobleUplift Nov 25 '16 at 20:41