Installing zlib, libpng & loadpng for MSVC

This is one way to get PNG support working with Allegro on MSVC. I'm assuming you already have MSVC and Allegro set up on your machine.

This guide is incomplete! The only copy of MSVC I have is the free command line version that Microsoft provides. Any updates to this document would be appreciated.

  1. Download the precompiled zlib and libpng packages from

    For the extremely lazy, just left-click these:

  2. Run the installers just downloaded. When prompted, point them to your MSVC root directory, e.g. c:\msvc (it should contain the include and lib directories directly inside it). You don't need to install the documentation or download sources if you don't want to.

  3. Important: Open up the zconf.h file in your MSVC include directory. Search for the line "#if 1 /* HAVE_UNISTD_H ... */" and replace it with "#if 0 /* HAVE_UNISTD_H ... */". zlib and libpng are now installed.

  4. To test loadpng, unzip loadpng somewhere. XXX: Sorry, you'll have to figure out the rest on your own. Try chucking loadpng.c, savepng.c, regpng.c along one one of the example programs into a new workspace.

  5. To use loadpng in your own application, I suggest you copy loadpng's source files into your own project directory and compile them as if they were your own files. Otherwise you may do whatever it is MSVC users do to turn loadpng into a library and install it on your system.

  6. When linking your own programs, remember that you need to link in the zlib and libpng libraries, as well as loadpng itself.

Go back

Back to Psyk Software homepage.