More people have asked for including the GD module in this documentation set. So I finally had the time to research this and write it up and give this to you.
First download the source code from the Freshmeat libjpeg project. I’ve used the source file jpegsrc.v8a.tar.gz.
First unpack the source code and then go into the folder “jpeg-7″ for the source and execute the following commands:
cp /usr/share/libtool/config/config.guess .
Which will copy these files to the current directory. They are required for the configuration fase of this installation.
Next for 64 bits systems use:
CFLAGS="-arch x86_64" \
CXXFLAGS="-arch x86_64" \
LDFLAGS="-arch x86_64" \
./configure --enable-shared
For 32 bits systems use:
./configure --enable-shared
For all use
To compile and
To install the library.
Next step is to recompile the php installation as described on this page:
Compiling PHP in 64 bits mode on Snow Leopard
The only change you need to make is to add:
--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:
CFLAGS="-arch x86_64" \
CXXFLAGS="-arch x86_64"
./configure --prefix=/usr/local/php5 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--with-config-file-path=/etc/php.ini \
--with-zlib \
--with-zlib-dir=/usr \
--with-openssl \
--without-iconv \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache2/bin/apxs



7:30 am
Just for your info(perhaps you already know), jpeg is not up to version 7. The source can be downloaded here
http://www.ijg.org/files/
12:36 pm
@Drew, thanks I will test it as soon as possible. Did you use it and encounter any problems?
12:46 am
I just tried with version 7, using your latest config above. Edited the makefile as suggested on the PHP 64bit compilation page, and get this:
Undefined symbols:
“_libiconv”, referenced from:
__php_iconv_appendl in iconv.o
__php_iconv_appendl in iconv.o
_php_iconv_string in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_substr in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_encode in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
6:25 am
@Richard, I didn’t have any problems at all. It was easier than the old one. Just standard ./configure && make && sudo make install.
works great so far.
7:44 pm
@Aaron, you compiled the GD library and PHP for different architectures. So you mixed up 32 bit and 64 bit compilation. This will cause the error you encountered. Try compiling both again with the same compiler flags.
1:06 pm
@Drew, tested version 7 and it works perfectly. I’ve updated the page to reflect the change.
2:24 pm
I had some problems as well with the iconv not resolving while having gd enabled. It seems PHP compiles the GD lib in 32bits or somethink, so adding the -arch x86_64 to GDLIB_CFLAGS solved the problem for me.
7:46 pm
works great with version 7, thanks!
8:51 pm
Hi,
I tried the installation above without any sucess at all… Would you mind updating it to a (sort of) tutorial???
I’m actually trying to have 64-bit PHP (version 5.3.1) + GD + jpeglib + pnglib support…
You seem to be the only kind soul across the internet willing to describe in an article how to proceed with the installation…(!)
Many Thanks,
Guizola.
9:58 pm
@Guizola, how much more of a tutorial would you like to have. This is GD with jpeg and png included? You need to combine this page with another one on the site: http://diymacserver.com/installing-php/compiling-php-in-64-bits-mode-on-snow-leopard/
11:20 pm
I got the following (using the 32-bit configuration in this article):
configure: WARNING: unrecognized options: –with-config-file-path, –with-zlib, –with-zlib-dir, –with-openssl, –without-iconv, –enable-exif, –enable-ftp, –enable-mbstring, –enable-mbregex, –enable-sockets, –with-gd, –with-jpeg-dir, –with-png-dir, –with-freetype-dir, –with-xpm-dir, –with-mysql, –with-pdo-mysql, –with-mysqli, –with-apxs2
…at the end of the installation.
Does that represent a problem? ‘Cause I’m having problems with my PHP script which I don’t know if they are “inherited” from the installation in this article or not…
8:40 am
@Guizola Yes, you need to use -- instead of - for the options. Somehow you have a problem copying the text.
5:59 am
[...] http://diymacserver.com/installing-php/adding-the-gd-module-to-php-on-snow-leopard/ Categories: System Administration Tags: 10.6 Server, Freetype, GD, PHP 5.3.1 Comments (0) Trackbacks (0) Leave a comment Trackback [...]
11:56 pm
Hello,
I got a big problem.
After make and make install of jpegsrc.v7.tar.gz
I get in /usr/local/lib : libjpeg.7.dylib libjpeg.a libjpeg.dylib libjpeg.la
When I wanna compile Php with theses parameters :
MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS=”-arch x86_64 -g -Os -pipe -no-cpp-precomp”
CCFLAGS=”-arch x86_64 -g -Os -pipe”
CXXFLAGS=”-arch x86_64 -g -Os -pipe”
LDFLAGS=”-arch x86_64 -bind_at_load”
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure –prefix=/usr \
–mandir=/usr/share/man \
–infodir=/usr/share/info \
–disable-dependency-tracking \
–sysconfdir=/private/etc \
–with-apxs2=/usr/sbin/apxs \
–enable-cli \
–with-config-file-path=/etc \
–with-libxml-dir=/usr \
–with-openssl=/usr \
–with-kerberos=/usr \
–with-zlib=/usr \
–enable-bcmath \
–with-bz2=/usr \
–enable-calendar \
–with-curl=/usr \
–enable-exif \
–enable-ftp \
–with-gd \
–enable-gd-native-ttf \
–with-jpeg-dir=/usr/local \
–with-png-dir=/usr/X11R6 \
–with-freetype-dir=/usr/X11R6 \
–with-xpm-dir=/usr/X11R6 \
–with-ldap=/usr \
–with-ldap-sasl=/usr \
–enable-mbstring \
–enable-mbregex \
–with-mysql=mysqlnd \
–with-mysqli=mysqlnd \
–with-pdo-mysql=mysqlnd \
–with-mysql-sock=/tmp/mysql.sock \
–with-iodbc=/usr \
–enable-shmop \
–with-snmp=/usr \
–enable-soap \
–enable-sockets \
–enable-sysvmsg \
–enable-sysvsem \
–enable-sysvshm \
–with-xmlrpc \
–with-iconv-dir=/usr \
–with-xsl=/usr \
–with-pcre-regex=/src/pcre/pcre-local/usr/local
PHP compiling is OK
But, when I do a phpinfo(), that’s I have on GD table :
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.9
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.2.35
WBMP Support enabled
XPM Support enabled
XBM Support enabled
Pleaaaassse, what’s the problem ????? jpeg is ignored ..
Thanks,
Arnaud
9:46 pm
It’s difficult to tell what is going wrong because it can be so many things. For instance did you compile everything for the same architecture (32 or 64 bits)
I and others have followed these same instructions without your problem. I would suggest, delete all previous attempts and start again from the beginning.
9:37 am
Thanks Richard,
how can I delete all previous attempts ?
When I start from the beginning, I restart from compilation and I do all the steps (compilation / make / make install and restart apache)
Maybe I have to check of all is 64 bits compiled.
8:38 pm
Delete all the stuff you have downloaded and unpacked, do it again from the start ad make sure you follow the instructions for either 32 or 64 bits depending on what your computer is capable of. You can check by entering on the commandline “httpd -V” there is a line which tells you which architecture you are on.
Please stop spamming your problem on each relevant page on this site otherwise you are forcing me to delete them all.
12:25 am
Hello,
thanks Richard, if you want you can delete others spamming posts.
If it can help somebody, I typed the first commands without \ or not separatly.
Exemple :
export MACOSX_DEPLOYMENT_TARGET=10.6 + return
CFLAGS=”-arch x86_64″ + return
CXXFLAGS=”-arch x86_64″ + return
.configure [...] + return
OR
export MACOSX_DEPLOYMENT_TARGET=10.6 \
CFLAGS=”-arch x86_64″ \
CXXFLAGS=”-arch x86_64″ \
.configure [...] + return
64 bits architecture were not used, but now all is solved.
Cya
Arnaud
1:42 am
[...] Download and build GD; [...]