Wednesday, March 14, 2012

Compiling zziplib with MinGW

In our platform game, we use the zziplib-library to access game data files from within a zip archive. On a Linux system zziplib is easy to install via the package management system, but on Windows it is more challenging. I could not find the library precompiled, so I compiled it myself with MinGW. Here is a list of the necessary steps and tweaks. In addition to MinGW, msys is needed (to run the configure script). Python is needed during the compilation, apparently when formatting the documentation. Either one has to disable  the documentation step (but I don't know how) or have a Python interpreter in the PATH. Since I have the great drawing program Inkscape installed and it ships with Python, I just added that python interpreter, C:\Progra~1\Inkscape\python to the system path. Note that spaces in the path lead to problems, for that reason I used the name C:\Progra~1\...

Get zlib. The header files, lib files and the dll are needed. Download both "Binaries" and "Developer files". Put them where they will be found during the compilation, I chose C:\mingw\include for the header files and C:\mingw\lib\ for the lib files. The file zlib1.dll should be in the same directory as the application.

Download the latest version of zziplib. Extract it somewhere, make sure there are NO SPACES in the path. Turn off any anti-virus software for the duration of the compilation process. At least f-secure often pretends to find viruses in files compiled with gcc. Also, any antivirus program may interfere with the configure scrips in the following steps, if it opens a file which the script creates and then quickly wants to remove.

cd to the zziplib directory. Edit the file configure. Replace uname -msr by uname -ms in two places. This is necessary, since uname -msr returns a string containing brackets. This string is used as a directory name, and for that brackets are not allowed. (This tip is from here, on the MinGW mailing list.)

Run sh configure --disable-mmap --prefix=C:/mingw/ . Without --disable-mmap the library compiles fine, but causes a segfault in some mmap function when accessing a zip file. --prefix describes where the header files and libraries should be installed. Then run make and make install.

No comments:

Post a Comment

Newer Older Home
Related Posts Plugin for WordPress, Blogger...