Compiling libpng for Mac OS X

I thought Mac OS X comes with libpng pre-installed. It's pretty clear that I was wrong after I failed to compile a game that uses libpng. The good thing about OS X is that, you can just use fink to easily install Unix/Linux binaries. However, the weird thing is, the game configuration still complains that libpng could not be found.

So I decided to install libpng from the source code. In case anyone of you out there who may face the same problem as me, you could do as what I describe below.

  1. Download the library source code from libpng.org.
  2. Untar it: $ tar -xjvf libpng-1.2.8.tar.bz2
  3. Go into the libpng-1.2.8 directory, and copy the makefile.darwin out
    $ cd libpng-1.2.8
    $ cp scripts/makefile.darwin makefile
  4. Run make: $ make (It's gonna take a while)
  5. Install the compiled library into appropriate place:
    $ make install
  6. Clean up the mess object files:
    $ make clean

That's it. The requirement, of which I should have mentioned earlier, to compile libpng is the zlib. I hope you have zlib installed first.

About these ads

6 thoughts on “Compiling libpng for Mac OS X

  1. chris price says:

    did the make test

    I got heaps of Filter 194** was used xxxxxxxxxxx times

    then a segment fault!

    ????

    but the libs were installed OK

  2. Anonymous says:

    Thank you for the procedure.
    I just had to modify a few things in the makefile:
    * “PNGVER = $(PNGMIN)”
    * ZLIBLIB=/Developer/SDKs/MacOSX10.6.sdk/usr/lib (ZLib is already installed in Mac OS X)
    * ZLIBINC=/Developer/SDKs/MacOSX10.6.sdk/usr/include

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s