Question: So far, I've made sure I've installed libpng and libjpeg with DarwinPorts (I'm running on OS X Leopard), but that doesn't seem to do the trick. I've read in a number of places that you need the development files (i.e. libpng-devel, etc.) as well to make this work. I'm a little lost. Can someone help me understand what I'm supposed to do? I'm happy to provide any more information that's necessary.

My configuration for PHP looks like:

```
./configure '--with-png-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-gd'
```

and I'm trying to install PHP 5.2.9. I've gotten the make to work without the '--with-gd' option. I've also been copying what I've found on various sites, so I might be doing something really wrong.

Answer: 
This error indicates that the libpng.so or libpng.a file could not be found. These files are created when libpng is compiled.

I don't know much about the Mac OS X way of installing things, but if you want to do it the Mac OS X way, you'll probably need to find and install that libpng-devel package.

Otherwise, you'll need to grab the source of libpng and compile it yourself. It depends on zlib, which you probably already have shared libraries for, but if not, you'll have to get that too.

[Here's a guide to compiling libpng on Mac OS X](http://kenno.wordpress.com/2006/04/20/compiling-libpng-for-mac-os-x/). It has a darwin-specific Makefile (not sure why that's needed, but worth a try).
I believe MacPorts installs by default to /opt/local not /usr/local? Maybe try /opt/local instead?

If you have fink, here's what I'm currently using (so i know it works) 

Here are the fink packages i have installed.

```
 i  libpng3 1:1.2.29-1  PNG image format handling library
 i  libpng3-shlibs  1:1.2.29-1  Shared libraries for libpng3 package

 i  libjpeg 6b-17   JPEG image format handling library
 i  libjpeg-bin 6b-17   Executables for libjpeg package
 i  libjpeg-shlibs  6b-17   Shared libraries for libjpeg package

```

Then to configure those parts of my php I use

```
'--with-gd' \
'--with-jpeg-dir=/sw' \
'--with-png-dir=/sw' \

```