Richard
If you want to do some graphics work within PHP you will need the GD library. It will take several steps of preparation before you can add this to PHP. First you need to download the source code from the Freshmeat libjpeg project.
First unpack the source code and then go into the newly created folder and execute the following commands:
cp /usr/share/libtool/config/config.sub . cp /usr/share/libtool/config/config.guess .
Which will copy these files to the current directory. They are required for the configuration phase of this installation.
Next for 64 bits systems use:
export MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch x86_64" \ CXXFLAGS="-arch x86_64" \ LDFLAGS="-arch x86_64" \ ./configure --enable-shared
For 32 bits systems use:
export MACOSX_DEPLOYMENT_TARGET=10.6 ./configure --enable-shared
Next follow with the commands:
make sudo make install
To compile and install the library.
Next step is to recompile the php installation as described on this page:
Compiling PHP in 64 bits or Compiling PHP in 32 bits depending on your requirements.
The only change you need to make is to add:
--with-gd \ --with-jpeg-dir=/usr/local/lib \ --with-png-dir=/usr/X11R6 \ --with-freetype-dir=/usr/X11R6 \ --with-xpm-dir=/usr/X11R6 \
To the configure statement and it will include this library for you.
For example when compiling in 32 bits use:
./configure --prefix=/usr/local/php5 \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --sysconfdir=/etc \ --with-config-file-path=/etc \ --with-zlib \ --with-zlib-dir=/usr \ --with-openssl \ --without-iconv \ --enable-exif \ --enable-ftp \ --enable-mbstring \ --enable-mbregex \ --enable-sockets \ --with-mysql=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-gd \ --with-jpeg-dir=/usr/local/lib \ --with-png-dir=/usr/X11R6 \ --with-freetype-dir=/usr/X11R6 \ --with-xpm-dir=/usr/X11R6 \ --with-apxs2=/usr/local/apache2/bin/apxs
By the way if you run into the error:
checking for jpeg_read_header in -ljpeg... yes configure: error: libpng.(a|so) not found.
You didn’t install X11 when you installed OS X. You can still install it using the “optional installs” and select X11 from Applications and install it on the default location.



Comments
10:50 am
i’ve the following error:
configure: error: jpeglib.h not found.
please help!
12:17 pm
@Nelson, did you install X11?
12:53 pm
thanks for the reply.
yes it’s installed.
i’m a newbie in unix (about 20 years that i do not touch in a terminal console) and now i need to setup a local testing environment for web development, and to test e-mail messages from the local website (with forms data or login of new users).
Let me say that you step by step tutorial is magnificent, the problem lays on the one that reads (me).
thanks.
5:12 pm
hey Richard, it’s just an fyi:
the homepage of “Independent JPEG Group” at http://www.ijg.org shows version 8d as of Jan 15 2012.
While at http://freshmeat.net/projects/libjpeg/ they still have version 8c listed to be the most recent one.
cheers mono