While developing a site which did some image resizing, I noticed this morning that Apple’s version of php5 which is shipped with Leopard didn’t have this library available! It does seem a rather odd omission, given that it’s probably one of the most commonly-used libraries behind mysql/mysqli.
A quick Google revealed that I’m not alone in this, and indeed Apple Discussions has threads on this particular subject albeit for Leopard Server (I’m running the bog-standard desktop edition). After trying a few solutions, I found that the Hill’s Dorm tutorial on installing GD gave the best pointers.
There are a couple of gotchas:
- Don’t use the Darwinports version of libjpeg – it’s a 32-bit version. This wasted half an hour while I tried to work out what was wrong only to find that I had the 32-bit libjpeg installed when everything else (including php5 and apache2) were 64-bit; the instructions given on the tutorial above does tell you how to build 64-bit versions of things which any recent Intel MacBook will require. A telltale sign of this is seeing in your logs: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ – (null) in Unknown on line 0 if you’ve got the wrong architecture (you might also see architecture errors in config.log if you’re really mismatching stuff).
- Don’t assume it’s not working because the command-line edition doesn’t work. This had me foxed and indeed seems to be that the CLI version of pph5 which Apple supply hasn’t got the capability to load dynamic libraries. The error is along the lines of dyld: Symbol not found: _php_sig_gif and puts the CLI version of php out of action pretty much.
I’m sure a more elegant solution will be along sometime, but for the moment this does seem to work.