Compiling the zlib compression library with Visual Studio 2013

Software

I you need zip compression in your development project, the zlib library is a good and free solution.
There’s however a bit of googling necessary to achieve a successful compilation with VS2013, especially for generating the 32 bits version of the library.
As I just needed it for some VB/VBA integration, I had to sort out a lot of outdated and not really useful information, for a simple solution, after all.
So here’s my receipe which will help you save some time, I hope, if you’re on the same track.

Update #2, 11/12/2013, here are my compiled binaries, zlibwapi32.dll and zlib64.dll in this zip archive, MD5: eb8932beb0360b42c6cdd1ccd79745ad

Download the library source code here: http://www.zlib.net, then:

  1. Uncompress the archive (in my case zlib-1.2.8.zip), you’ll find a zlibvc.sln file in the contribvstudiovc11 subfolder, that you can open with vs2013 (let it do its conversion stuff);
  2. The annoying part comes if you’re compiling against a Win32 target, because you then have to specify an additional linker command line switch /SAFESEH:NO. Right-click the zlibvc project and open its property pages:
  3. vs2013compile
  4. Do the same for the testzlib project
  5. Give it a go.

For the Win64 version, the linker switch does not apply, just go directly to the build process.

Note that you’ll end up with a zlibwapi.dll file that you can use with your vb/vba projects.
I did compile 32 and 64 bits versions of the library, and I renamed them zlibwapi32.dll and zlibwapi64.dll to avoid confusion; here are the declares for the 32 bits version:
(Updated 11/12/2013)

It’s then quite easy to figure out how to use the functions in your C/C++/VB/Whatever projects, samples are included with the library, but for VB/VBA, here is an excellent introduction from Mike D Sutton: http://edais.mvps.org/Tutorials/ZLib/index.html .
Happy zipping!

4 comments… add one

Leave a Comment