The Linux Page

Compiling zlib for Win32 with MinGW

I have had a BIG problem with compiling zlib. Now I have my own normal configure.ac file, but the most important part of that compile was for me to find out how on Earth can you generate the dynamic library (.dll and .dll.a files) instead of the static library (.a only file)?!

The fact is that the libtool utilities will generate a DLL only if you tell it that all the symbols are properly defined. Otherwise, it fails that very test and decides that it cannot create a DLL, automatically reverting to the static library. The problem here is until you actually really link you cannot know whether some symbols are missing. Thus the decision of the libtool folks.

This is not so bad, in itself, it just made me lose a lot of time to look for the correct option again and again. Now, I'm writing the solution here to try to remember it forever...

So... before calling my configure script, I set CFLAGS as follow when I want to cross compile from my Ubuntu box:

	export CFLAGS="-I$MO_PREFIX/include -O2 -mwindows -mno-cygwin \
				-mms-bitfields -march=i686 -no-undefined"

Hope this helps! At some point, I will post my version of the zlib modified with my configure script. That way everyone can enjoy it instead of trying to use the default zlib configure that is not generated with automake, libtool & Co.

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.