Friday, May 11, 2012

Issues I encountered when compiling LibXML2 as a shared library

I suppose most of you are aware that when you extract the libxml2 source, there is a folder called win32. Inside is a configure.js which works like a charm, and a makefile.mingw which is what I use.

The Makefile.mingw file needs to be manually edited with paths where the *.o file will reside, otherwise it will fail immediately.
Other than that, a static library is produced. So far so good, but I needed a shared library as well, one which wasn't produced with that specific Makefile.

I CD'ed back once, and used the default ./configure file, which produces not only a static library, but a shared one as well, and the size is even smaller than the one from the Makefile.mingw file in the win32 folder.
This is where the problems begin. Linking my application with either library caused a crash in my application.
The crash was specifically caused by the library being built with pthreads support(not with pthreads-win32 compatability apparently), instead of native thread support for Windows.

I then went to the XMLSOFT mail list, where I wrote about my issue and it was suggested to apply a patch to enable win32 thread support by default on Windows based machines.
After applying the patch, the output from the compilation suggested enabled native thread support, as did the config.log file, unfortunately the libraries built still caused a crash in libpthread-2.dll, apparently it was still built with pthreads support.

I then CD'ed into to the win32 folder and produced the stable static library, which although it increases the overall size of my app by at least 900KB, it causes no crash as it uses native Win32 threads.

As of writing this post, I've yet to find a solution.

No comments:

Post a Comment