Adding GD Library for Mac OS X Leopard
Thank you ever so much Alex, for pointing some inaccuracies of my post. And thank you for provide such ever an accurate and great tutorial for us.
As Alex released a really perfect tutorial for helping us to adding the GD Extension to PHP5 on OS X Server 10.5.x. I was deleted my tutorial 2 weeks ago because I don’t think my tutorial is useful anymore. And Alex is really conscientious! He has updated his tutorial again, but he seems forgot something(i’m not sure), so I write a “how to” again, any way, most of I write following is a copy of his, so, thank him again for giving us such a great stuff.
OK, So let’s get going:
1.Requirements
- You have made a backup of your system.
- You have the latest version of Apple’s Developer Tools (XCode 3.0 or higher for 10.5.x) installed. Dev Tools are available on your Server DVD and as a free download from Apple’s Developer Connection.
- X11 is installed (part of standard OS X Server install unless you deselect it)
- X11 SDK is installed (available on your OS X Developer Tools Disc or Image and part of the standard installation. This is different from the X11 client that comes with OS X.)
- You do have a backup
- You are running 10.5.x
- You have not manually updated anything related to GD, libpng, libjpeg and freetype so far (if you have, you must know how to adapt these instructions to the changes you made).
2. Getting and installing libjpeg
- 2.1 Create a temporary folder named SourceCache in your Macintosh HD
- 2.2 Download libjpeg and extract it to “SourceCache” folder.
- 2.3 Open your Terminal
Make sure you are logged in as root.
(Optional: If you haven’t enabled root user yet, open “Directory Utility.app” in /Applications/Utilities, and choose “Edit” option → “Enable Root User” and then, set a root password.
And Open “Terminal.app” in /Applications/Utilities, type “su” and password to login as root.)
Type:
cd /SourceCache/jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
For 32-bit use:
./configure --enable-shared
For 64-bit use:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure --enable-shared
and type this to install:
make
mkdir -p /usr/local/include
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
mkdir -p /usr/local/man/man1
make install
3. Getting and installing the GD Graphics Library extension
- 3.1 Download PHP source and extract it. (php-5.2.4 is recommended, because that is the same version with the one pre-installed in Leopard.) and copy the extracted folder to “SourceCache” folder.
- 3.2 Install GD library
type:
cd /SourceCache/php-5.2.4/ext/gd
phpize
For 32-bit use:
./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
For 64-bit use:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
and then, type:
make
make install
4. GD extension integration
- 4.1 Modification of your php.ini file
(Please note: Apple’s stock server installation does not come with a “php.ini” file but “php.ini.default”)
If you don’t have a “php.ini” file in /etc, just rename “php.ini.default” to be “php.ini” (Administrator password required)
Add this line in php.ini file
extension=gd.so
- and search this line in php.ini (VERY IMPORTANT)
extension_dir = "./"
- DISABLE IT BY ADDING A SEMICOLON (;) IN FRONT OF THIS LINE AND SAVE CHANGE.
4.2 Edit apache2 configuration file
Open httpd.conf in /etc/apache2 and search “php5_module”
Enable it by deleting the “#” and save change.
4.3 Create a phptest.php file with the code following:
<?php
phpinfo();
?>
- and locate in /Library/WebServer/Documents.
4.4 Restart Apache and test
Open System Preference → Sharing and check the “web sharing” option
and visit http://127.0.0.1/phptest.php
If you get this, you get through, well, good luck!







Thanks for your very helpful tutorial.
I have followed it and everything seems to have installed properly, yet when I check the phpinfo, there is no sign of GD at all.
Any suggestions?
Hi . . I followed the above step by step and I thank you for your tutorial.
Just like the reader above . . no sign of GD in the test.php file.
I would be most grateful for any fix.
Please be in touch
Big thanks,
to Chris and Glen
Thank you for visiting.
And there are two points taht we should pay attention:
1.make sure there’s no error while you make install, sometimes, you will get errors, that’s normal. please retry to install, if you get error, please read carefully the error log and re-configure and re-make install.
2.the 1st time I failed too, because I didn’t edit the php.ini file
add 2 lines in php.ini:
; Enable gd extension moduleextension=gd.so
and add a ” ; ” in front of this line:
extension_dir = "./"and after adding, like this
; extension_dir = "./"by default, the file is named “php.ini.default” , just rename “php.ini.default” to “php.ini” and then, edit it
and save php.ini, restart apache and test
Thank you for the tutorial: well written and easy to understand.
I just have a little trouble when “making” the integration of GDlibs in php:
/php-5.2.4/ext/gd/gd.c:81:24: error: ft2build.h: No such file or directory
/php-5.2.4/ext/gd/gd.c:82:12: error: #include expects “FILENAME” or
make: *** [gd.lo] Error 1
a.
to alfonzo
Hello Alfonzo
you get this error because you don’t have X11 SDK installed with your Xcode.
what you shoud do is just install X11 SDK for Xcode. X11 package is in your /leopard DVD/Optional Installs/Xcode Tools/Packages/X11SDK.pkg
and then, run
cd /php-5.2.4/ext/gdsudo phpize
./configure --with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/local/lib \
--with-zlib-dir=/usr
make
sudo make install
hi! thanks, neat tutorial, a big help. but i got a problem: everything makes and installs fine, if i fire up apache again i get the following error in the apache-log:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
any idea?
tnx serum
I got the same thing as Chris and Glen — installation went through without a hitch, but no sign of gd after restarting apache…
to serum
I think you didn’t perfectly edit php.ini file. By default, in the dictionary /etc ,you will find a file named “php.ini.default”. rename it to “php.ini” and then, edit it with your favorite editer and add to lines:
; Enable gd extension moduleextension=gd.so
and searche these words: extension_dir = “./”
and add a “; ” ( a semicolon and a space) in front of this line. like this
; extension_dir = "./"save itPlease attention ! you forget to add a semicolon in front of
extension_dir = "./"caused this error !save php.ini and restart apache.
to Jason
please check apache’s error log and tell me what’s going on.
use this command in terminal:
tail /var/log/apache2/error_logHi again . . . . No I CAN DEFINITELY VERIFY that after I followed your steps, I opened PHP.ini.default and edited EXACTLY as you described above . . and saved it as PHP.ini in the same directory.
I am aware of those important points you brought up and actually REINSTALLED leopard from scratch again . . . and ran through your whole procedure step-by-step again.
Grrrrrrrr. Seems to all work great, but GD just doesn’t show up when hitting TEST.PHP at the end after restarting Apache.
I am gonna try it a 3RD time and get back to you.
Perhaps you could do it all again over a Default install of OSX.5/with X11 and Xcode 3 . . . . and VERIFY or provide a downloadable TEXT file in Plain text format to copy and paste line by lien into the terminal.
If you can help me get PHP with GD working here . . it would make you my new best friend.

Turning display_startup_errors = on in my PHP.ini, I get the same error as user “serum” above: PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
Everything appeared to make and install fine.
Thanks for taking the time to put together this tutorial, it’s really appreciated!
I’m not sure if the instructions are complete. I ran into trouble and found it easier just to hack the entropy installation as show here:
http://www.entropy.ch/phpbb2/viewtopic.php?t=2867
I did have to do one weird thing, which was to symlink to:
/usr/local/apr/lib/libexpat.0.dylib
Ross, I have replied serum, please check your php.ini
disable this line:
extension_dir = "./"if you don’t understand how to disable it, just delete this line.
save php.ini and restart apache
to Chris
I updated this article and provided a txt file to show you what you should type in terminal. download here
by the way, what we need is X11 SDK, that is available here: /leopard DVD/Optional Installs/Xcode Tools/Packages/X11SDK.pkg
This is different from the X11 client that
comes with OS X
To Glan
Hi, you got through with entropy’s PHP package?
and I don’t think that hack entropy’s package is a quite easy case.
I just provided a txt file ( there are all command lines we should type in terminal ) and my php.ini
Because of the difference between HTML and txt, I think to provide a txt file is better. you can copy the commed lines in the txt file and paste in terminal and if you want, you can also replace your php.ini with mine.
download here
Hi Hill -
Thank you for your work on this! Okay - as you requested I checked my error log and I get the following:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
I also went ahead and replaced my php.ini with the one you provide and restarted apache and…. no luck.
Thanks again…
Hill . . .very big thanks for your effort . . but and I did the following AGAIN. In exactly this order.
1. CLEAN INSTALL of MAC OS X.5 Leopard
2. New Install of X-CODE 3 AND X11 AND X11 SDK
3. Created root password to be able to log in as root.
4. Enabled PHP by un-commenting the “load module PHP 5″ line
5. Restarted Apacheand hit “test.php” in home/sites folder.
6. Works so far . . Apache 2 & PHP is up and running.
7. Downloaded the instructions and followed them AGAIN. . . including the text file (thanks for that by the way) . . . . had NO problem following every step one-by-one.
8. Took your provided php.ini file and dropped it into /etc . . . restarted Apache . . .
Nothing.
PHP works fine . . . . But No GD.
I just don’t get it. ;(
A thousand thanks for your efforts.
unfortunately I have X11SDK installed with Xcode.
but thanks anyway…
when I’ll find a fix for this (very soon, I hope), I’ll post it here.
bye
a.
to Jason
Normaly, That you didn’t rihgt configure your php.ini caused this error. if you don’t mind, please sent me your php.ini by mail athuque@hotmail.com.
Hi Chris
actually, i have no idea what’s going on with your installation.
if you don’t mindm please check your apache’s error log and tell me the detail and please send me your php.ini by mail athuque@hotmail.com.
thank you
SOLUTION!!!!!!!!!!! AND IT ONLY TAKES about 30 seconds!!! PHP5 with GD support and everything else listed below. PHP Tried. GD Tested and Works!
Here is a .tar.gz of the current state of the PHP5 for Leopard. . . .
http://www2.entropy.ch/download/php5.leopard.20071101.tar.gz
1. Download it.
2. Simply movie/drag the whole upzipped folder and drop it into usr/local/ (so the path to the folder is /usr/local/php5). You will be prompted to Authenticate the move.
3. Manually edit the /etc/apache2/httpd.conf file to load /usr/local/php5/libphp5.so
The uncommented line should read. . . .
“LoadModule php5_module local/php5/libphp5.so”
(no quotes of course)
4. Restart Apache and hit your test.php file to verify that GD is now listed as an extension.
It currently has these extensions:
libxml2
libxslt
gettext
curl
iconv
GD with libpng libjpeg libfreetype
mysql
postgresql
and these options:
openssl
zlib
ldap
xmlrpc
exif
soap
sqlite-utf8
wddx
ftp
sockets
bz2
zip
pcntl
shmop
sysvsem
sysvshm
sysvmsg
memory-limit
mbstring
bcmath
Im very pleased.
And I hope this helps.
I found the info HERE –>> http://www.entropy.ch/phpbb2/viewtopic.php?t=2668&start=75&sid=4f798b81869a52e1cff9af2d970d25fc
CHeers!
Hill,
Thanks for your reply. I double-checked my php.ini and it makes no difference if I comment out that line or not. I verified using phpinfo that the reference was accurate and it showed the updated values when I restarted Apache, but I am still getting the “PHP Warning: PHP Startup: Unable to load dynamic library”.
Again, I appreciate your time in putting together this page and in helping those of us with difficulties in getting things debugged!
Bravo Chris
Thank you very much and good job chris and liyanage, you can use his package to enable GD.
Thank you for your excellent turorial.
However, I get an error when executing the line:
sudo ln -s /usr/X11R6/include/fontconfig /usr/local/include
as /usr/local/include already exists in my filesystem.
could this be a typo?
Thanks for almost literally transcribing my instructions on building the GD Graphic Library on Mac OS X Leopard. At least you had the decency to mention that you looked up our tutorials on topicdesk.com.
Unfortunately, you are basing this on instructions which are obsolete and install stuff that isn’t needed. zlib and libpng are already present in the X11 tree. Installing them again will leave you with two instances which can cause issues. This is why we have split the GD tutorial into a Tiger and a Leopard version.
The reason we have yet to publish instructions on how to tie GD into PHP5 on Leopard has to do with several changes made by Apple and we rather test once too often. As you know you can either integrate a module or re-build PHP5 to add functionality. Both methods have pros and cons and especially on OS X Server can have side effects on the functionality of other software.
Regards,
Alex
topicdesk.com
Hill, thanks for the link and for your contributions to the Mac community.
Regards,
Alex
Hey Alex, these words, we should say them to you! thank you!
Hi, very interesting things, but, on my Terminal, impossible to install GD, because I have the following message :
checking for gcc… gcc
checking whether the C compiler (gcc ) works… no
configure: error: installation or configuration problem: C compiler cannot create executables.
I installed gcc 2.95, and gcc 3.1 and gcc 3.3, but only the same message …
I installed X11 SDK, but always …
I am very desappointed … I was many esayer on mac os 10.4 …
If you have an advise, thaks a lot …
Marc
to VALLETEAU de MOULLIAC
je pense que vous avez reçu cette message c’est parce que vous n’avez pas installé le Xcode. Cette message que vous avez reçu a dit que votre C compileur ne marche pas. Donc… peut-être c compileur n’existe pas. je vous propose de reinstaller Xcode (si vous êtes sur que vous avez l’installer déja), et après refaire dessu.
bonjour Marc ,ou bonsoir
une chose je voudrais savoir, est-ce que vous avez reçu la même message quand vous installez l’autre chose, par example libpng,libjepg,zlib et caetera ?
si il n’y avait pas de probleme quand vous avez installé l’autre chose, franchement, je ne sais pas ce qu’il faut vous propose.
Sorry, I cannot make the GD extension work on my Leopard client, although the tutorial is really comprehensive. I just build a full set of Apache 2.2.6, PHP 5.2.5, MySQL 5.0.45, Subversion 1.4.5 on Leopard client. Go to http://www.phpex.net/home/entry/10 for more information and downloading.
呵呵,karajanlee
其实alex的教程上已经指出最后还是需要把GD extension 连接到php上的,但是他的教程上就是说了一下,没有告诉你怎么做,所以你照他的教程弄完之后在php info页面是无法看见GD的信息的。
其实只需要下载php5的source文件,然后把php-5.2.4/ext/gd目录下的 gd 代码用phpize命令跑一下就可以了。
我确实很佩服你的勇气,居然重新安装了一个apache2,虽然和预装的apache以及php不会冲突,但是不会有那种怪怪的感觉吗,觉得系统里面有多余的程序,有垃圾文件的那种感觉,反正我是不舒服
我的msn是athuque@hotmail.com,你有兴趣可以加我一下
Pour Hill. Merci de me répondre en français ! C’est assez difficile pour moi de tout comprendre en anglais, hélas !
Pour vous répondre, effectivement, j’avais installé un XCode périmé (1.3) et ai installé XCode 3.0. Mais je n’arrive toujours pas à installer GD. En particulier, les commandes ‘make’ ne veulent pas travailler.
Je suis en relation avec l’auteur du tutoriel ci-dessus (Athanasios Alexandrides) qui me demande :”Did you maybe at some point use Fink or MacPorts?” J’avoue que je ne comprends pas la question.
Je suis plutôt débutant avec Terminal, et assez déçu de voir qu’apple, encore une fois, ne va pas jusqu’au bout de ce que l’on attend de lui.
Merci de votre aide. Marc
to Chris :Thank you for your explanation, but they did not lead me helped
I downloaded php5 entropy, have installed in /usr/local, and then replaced in /etc/apache2/httpd.conf line LoadModule php5_module libexec/apache2/libphp5.so by LoadModule php5_module local/php5/libphp5.so …
But then, afer reload apache, localhost impossible to open … I handed the httpd.conf as before, and worked well apache.
Please advise … Thanks. Marc
@valleteau de moulliac
Oh, non…, tu a installé 2 versions différents de PHP: php5 de entropy.ch et php5 d’officielle ne sont différents. ça va être bordel après. cette fois, je te diras pas comment installer les trucs, justement, je vais copier quelque chose de mon ordinateur et après tu colles les trucs dans ton ordinateur, et c’est bon. dans 20 minutes, tu regardes ton email, ok?
par compte, c’est vraiment difficiles de dire le français pour moi, si y a bcp de fautes dans mon écriture, j’espere que tu peux comprendre, je suis chinois.;)
to Hill
merci pour tes commentaires, et, franchement, je trouve que ton français est bien meilleur que mon anglais !
Je viens de voir ton mail sur ma machine … Je te répondrai directement, ok ?
Merci. Marc
Excellent!!!
Thank you very much for working to solve this problem!
I followed your directions and it worked great for me - fantastic!!!
Now I can use the full power of Drupal 5.3 on my local computer.
Cheers
Jedaffra (Canada)
Thanks a lot !
I followed the tutorial and all works fine !
Please note that in Leopard (my version is not Server edition) some command like make install and copying files in system directories need the SUDO command.
Thanks again
Good work!
@ Massimiliano
Thank you very much for your comment and thank you again for reminding me about the “sudo” command. but, normally, before we type something in terminal, I am accustomed to login as root user with the “su” command. but thanks anyway.
by the way, I just looked around your site, your gallery is prefect!
Thank you so much, it worked perfect!
Great howto!
For some reason, I had to install t1lib; with DarwinPorts this works as follows:
$ sudo port install t1lib
Then add this to your configure command:
–with-t1lib=/opt/local
Just my $0.02…
For running su/sudo, instead of entering sudo in front of every command, just do ’sudo bash’ in terminal. That will provide you with a root prompt.
To use su/sudo, instead of entering sudo in front of every command, just do a ’sudo bash’ in terminal. That will provide a root prompt for entering the other commands.
For anyone getting the message:
PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
You are probably on a 64-bit machine, like a newer macbook pro with a CORE 2 DUO (not core duo). If this is the case, and you followed the 32-bit instructions the first time through, you should start over by uncompressing the downloaded archives again and using clean directories (i had some stray config / makefiles after going through the 32bit instructions).
http://blog.joel.co.uk/index.php?itemid=437&catid=7
@ Scott
yep, you’re right.By running some command in shell (like “configure”, “make”, etc.), the executable file “configure” will create some files needed for the next step.
you can run “make clean” command to clean the files or you can do it just like what you did: uncompressing the archives again and using clean directories.
Thanks Scott, I found out the same thing… and saw your post after.
To summarize:
For those experiencing the following error:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
Make sure that you compile for the right processor architecture… Unlike the Intel Core, Intel Core 2 is a 64-bit processor
This is VERY IMPORTANT, you will not get any other warning if you compile for 32 bit on a 64 bit machine.
If you recompile for 64 after trying 32 bits, make sure that you issue a “make clean” command before the “make” command.
Anyway, it should be made clear in the instructions, as many do think that 64 bits is for kick-ass servers only!
hello I am new to php and I have just enabled it on my MacBook Pro. I have tried to download from your links above and nothing is working. Please could you redirect me so I can put a gd library on my computer to test scripts for things like Captcha and other library necessary web apps. Thank you.
@matt
Thank you matt, and my sorry, and I have fixed the links and tested them
Thanks Hill.
You rule.
It took me two tries to get this right. The first time I followed the x86 instructions rather than the x64 instructions. It took me reading the above few comments to realize my error.
I have a website (locally) that uses a lot of GD for thumbnails, etc. It hasn’t worked since I upgraded to Leopard, in early November. As soon as I opened my browser, and saw that the site looked correct, I got all warm and fuzzy inside.
Thanks so much!
Benjamin
It’s working! Thank you so much. Now I don’t have any reason to use MAMP or XAMPP. I did a fresh install, added Xcode and X11sdk then followed your steps using 64bit option in my macbook core2.
Hi there,
Thanks for the great tutorial! I really appreciate your time and effort, you’ve certainly saved me a lot of both!
Much appreciated!
@Michael
your mac is a 64 bit machine ? if this is the case, run “make clean” in the Terminal and following the 64 bit instruction. try again.
@Hill –your mac is a 64 bit machine ?
Are you SERIOUS?
no. I don’t have enough money to change a 64 bit machine
Hi,
thanks for the article. This is almost identical except to another article @ http://osx.topicdesk.com/content/view/135/62/. (Found that one through the Apple Forums.)
However, to all the people that are having problems with GD not being installed (like I was), there is one small but significant difference in the installation instructions.
“Also, if you already had your own php.ini, make sure the
extension_dir= setting is not overriding any defaults. If in doubt,
comment it out or point to the directory gd.so was installed into (usually
/usr/lib/php/extensions/no-debug-non-zts-20060613)”
My extension_dir line reads:
extension_dir = “/usr/lib/php/extensions/no-debug-non-zts-20060613″
As Hill says, the “./” is a problem for some reason and I had to remove it. But this process he takes us through puts the gd.so in the above directory and it needs to be included. Once I did this, it all worked great! Thanks to both authors for a diligent and thorough write-up.
hey folks
i would like to thank you for the article. On my desktop imac I follow the article’s instruction to install the GD extension NP.
However when I tried it on my macbook pro I cannot get it working. It turns out I have my previous darwin installation having the path /opt/local preceding other PATH.
In order to avoid this problem make sure you do a which on phpize and ensure its path is /usr/bin/phpize.
Also make sure your PATH variable does not contain the /opt/local ….
I hope this helps.
Best Regards,
Bruce
@Hill
Thanks a lot for your appreciation !
Hello I tried to download the file php5.leopard.20071101.tar.gz from the link above but its gone now.
I am in the same boat, I cant get GD Library to come up.
Macintosh…
Its fried rice, you plick!…
Thanks for great tutorial. It was very helpful. Got stuck when I used 32bit instead of 64bit. Maybe a note or link at in the tutorial to explain the difference. Thanks!! -enrique
I’ve tried for a while to get this to work without any progress. Is anyone able to make a package for the GD library? ‘Cause this is just too frustrating.
Ok, it’s working better…
I have a Intel Core2Duo MacBook Pro. I’m a bit confused… Do I select the 32bit or 64bit installation?
Doing the 64bit installation did the job. Just had to restart my Mac. GREAT WORK!!!
Um, how do I remove XCode?
@ sebz
oh. no no no no….
please don’t uninstall your Xcode, because the Xcode is not only a developing tool but also a runtime library, it means, Xcode package installs some libraries you need, for example libpng, and your GD running needs libpng.
I think GD wouldn’t work if you uninstall XCode.
If you want to try a quick solution as mentioned in an earlier post.. there is now version 6 of march lynairges packages which adds GD amoungst others Leopard systems. Had it up and running in about 5 minutes…
http://www.entropy.ch/phpbb2/viewtopic.php?t=2945&postdays=0&postorder=asc&highlight=leopard&start=0
Fyi, there are myslq connection issues with the latest entropy beta 6 for ppc and/or 32 bit. Also, this is the correct line to put in httpd.conf if you are going to use the entropy build - the path Chris gave above is not correct.
LoadModule php5_module /usr/local/php5/libphp5.so
I dont’ get this … I spent about 5 hours on this and I still can’t get it working… main problem my standard leopard /w all the x11 stuff installed doesn’t have X11R6 dir why does your command reference that directory when it doesn’t come with it? txs
thank you. i spent ages trying to work out how to do this and i kept getting compile errors or just plainly not working. finally after following the instructions on this page i got it working! thanks again!
I encountered the same issue Chris and Glen did, i.e. the instructions went smoothly but there was no sign of gd in the phptest.php.
Before I try Chris’s ‘entropy’ solution, I saw SebZ’s comment about 32/64 bit. I have Intel Core 2 Due and it seems from reading the above that I should have used the 64-bit version. . . oops.
If I want to go back and try the 64-bit version, how much of what I’ve done do I need to undo, and how do I do it? As it stands I’ve completed the entire instructions above (32 bit versions) and closed down everything (Terminal etc).
Thanks for any advice!
Thanks a lot for your great tutorial. For me it worked!
Thanks again.
Thanks a lot for your help! It worked like a charm!
Cheers!
This was a well written tutorial, but I did have some problems.
The GD directory does not show up in PHP.
I opened the error_log and this is what I got:
% Digest: generating secret for digest authentication …
% Digest: done
% Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured — resuming normal operations
% File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://localhost/phpinfo.php
% SIGHUP received. Attempting to restart
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/php_gd.so’ - (null) in Unknown on line 0
% Digest: generating secret for digest authentication …
% Digest: done
% Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured — resuming normal operations
% File does not exist: /Library/WebServer/Documents/favicon.ico, referer: http://localhost/phpinfo.php
What do you think the problem might be?
Clyde
Now I have GD and thanks for the great article.
However, after I have changed my php.ini, I have problems with the command line php.
php
dyld: NSLinkModule() error
dyld: Symbol not found: _php_sig_gif
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so
Expected in: flat namespace
Trace/BPT trap
Any suggestions?
subscribe above: on Mac Intel Core 2 Duo (an aluminium iMac) the 64 bit specs are required to install gd library. Also, open a session as superuser “sudo su” at the beginning of the installation.
It’s a useful piece of reference!!
I m running 10.5.2. Got the stuff compiled but doesn’t seem to work.
I m running iMac Aluminum so i used the 64-bit instructions. I got these errors:
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
Any suggestion what I can do?
Thanks a lot for your help.
Bill
Hi there
I followed your instructions and everything seemed OK till I got to this
checking for fabsf… yes
checking for floorf… yes
configure: error: libjpeg.(a|so) not found.
I get this after the below command
./configure –with-zlib-dir=/usr –with-jpeg-dir=/usr/local/lib –with-png-dir=/usr/X11R6 –with-freetype-dir=/usr/X11R6 –with-xpm-dir=/usr/X11R6
Any ideas?
[...] Tiger) to develop all the gallery code for a current client of mine. Luckily I stumbled across Chris’ comment on this post (the content of which I tried first, to no avail) and wouldn’t you know, it [...]
Unbe-F-ing-leavable
I had no clue what I was doing but I trusted your code, and it worked perfectly… all that I had to change was that for a few lines that were to be written in xterm, I got permission denied
So I just ran them with the word sudo before the command and it worked unbelievably!!!
I owe you a beer when you’re in San Diego! Email me if you ever are!!!
Thanks
Chad
I had idea that my Macbook is a 64bit machine until I encounter an issue while trying to follow your instruction..
GD works on my machine now! Thanks!
Absolutely fantastic. Nice explanation and perfect execution. Good work. Thanks.
[...] notes on getting PHP 5.2.5 to compile on Leopard, I discovered a fellow named Hill Pei had hacked GD support into the Leopard PHP without too much effort. His method simply requires some comfort with the command line and editing [...]
Thanks for the tip — everything worked as suggested.
Very good instructions. Worked without any issues at all. Thank You!
[...] is installed in the XAMPP package for windows. I have not installed the lib yet, but I found this page which explains a how-to, but by looking at the comments it seems that it is not as simple as it [...]
This great tutorial works like a charm - thank you very much
If you have trouble loading GD module and extension_dir is already fixed, please pay attention in the cpu architecture part (32bit/64bit) 32-bit PHP modules doesn’t work into a 64-bit subsystem.
To have root access (with blank Admin password) you can change it temporarily from System Preferences to make “sudo bash” work in terminal, in this way we can execute all commands mentioned in this tutorial more easily.
Cheers!
Martin
[...] I was a bit concerned about how many hours it would take to install the GD library. Thanks to http://www.veola.net/macintosh/adding-gd-library-for-mac-os-x-leopard it only took a few [...]
[...] was not configured to use the GD library. After some more searching I came across another tutorial on how to configure PHP with GD on a mac which worked [...]
From make test:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0
dyld: NSLinkModule() error
dyld: Symbol not found: _php_sig_gif
Referenced from: /SourceCache/php-5.2.4/ext/gd/modules/gd.so
Expected in: flat namespace
So, I had been following this tutorial since the release of Leopard and continuously ran into the problem Hans mentions above:
dyld: NSLinkModule() error
dyld: Symbol not found: _php_sig_gif
I am on the last revision of the MacBook, so I used the 64-bit instructions. Unfortunately, like many others here, I always assumed it was a 32-bit machine in the past.
Cleaning up your stuff is done with:
- make clean
- phpize –clean
However, how odd it may seem, it all started working when I actually did all of this in the /SourceCache/ directory. Previously I deviated from this and tried to work from /usr/src/
If you’re having problems, clean up your source directories, make sure you use the right instructions (check Wikipedia) and do this from the /SourceCache/ directory.
Hello Hill,
Unfortunately, I seem to be failing at the first step. I’ve downloaded the necessary tar files, but the following directory doesn’t exist:
/usr/share/libtool/
And despite having X11 installed, ‘make’ and ‘gcc’ don’t seem to exist on my machine. I’m a bit puzzled by this.
Any suggestions?
An update… I’ve successfully gone through all of the steps, but GD still doesn’t appear. I seem to be following in Chris’ shoes.
One interesting bit I noticed, setting my httpd.conf to “LoadModule php5_module local/php5/libphp5.so” (or “LoadModule php5_module /usr/local/php5/libphp5.so”) causes PHP to no longer work via Apache. I verified that libphp5.so is in that directory, so I’d appreciate any feedback on this (or with getting GD installed in general - the package from entropy.ch didn’t do the trick for me).
Thanks,
-ilija
Thanks for the post. Works like a charm.
Hi Hill,
thank you and Alex very much for this great tutorial. It works on first trial with a 10.5 Server system. I only have to restart the complete server after finishing the installation. Not only the apache.
As I said : thank you guys !
matz
Thanks for posting this, Hill. GD’s installed just fine (using PHP 5.2.5 that came with the Apple 2008-002 Security Update).
I got stumped a couple of times, though, so I’ll post this here to help anyone else for future references:
1. If the directory “/usr/share/libtool/” does not exist, you need to install Xcode Tools located from “Leopard DVD/Optional Installs/Xcode Tools/XcodeTools.mpkg”
2. Make sure you have the X11 SDK installed from “Leopard DVD/Optional Installs/Xcode Tools/Packages/X11SDK.pkg”
3. If you get permission denied errors when doing a “make install”, enter “sudo make install” instead and enter your password.
[...] In my work with SwishCMS, I needed GD. The best guide I found for that is http://www.veola.net/macintosh/adding-gd-library-for-mac-os-x-leopard. [...]
I followed the instructions (using 64 bit…I have a new Macbook Pro). It works with Apache, but the command line still fails with the missing symbol errors.
Then I noticed jpeg6b wasn’t building shared libraries.
No matter what I did, I could not get jpeg6b to build shared libs this way. It only would build static.
I ended up pulling down the Macports package. I used the various patch files in the jpeg library (I applied them to the jpeg6b source with patch -p0), and that got the thing to build…(using the 64-bit config above).
Everything went together, and then it _still_ doesn’t work (missing symbol _php_sig_gif).
Any ideas?
Ah. 10.5 software update bumped PHP to 5.2.5 (not 5.2.4)…I downloaded to newer source, and still no luck.
My guess is that Apple has this patched in some weird way…
First of all thank you for your tutorial and your help.
This is what I have done:
I’ve followed your html tutorial, Alex’s tutorial, and even your txt file (unfortunately this is only for 32bits) but without any success.
Everything is installed fine, without not error, using your php.ini but the error_log still says
“HP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0″
I checked the /usr/local/php5/lib/php/ dir and there is not any extensions directory over there.
could you please create another txt file for 64bits? I have noticed that you download and install more file over there and I wonder if this is the problem. It would be great also if you can explain how to clean all this mess and start with a new/clean installation.
Thanks in advance.
Sorry if this is a little long but I’m trying to help solve the
dyld: NSLinkModule() error
problem.
It sounds like this is a problem is shared by a few of us. My environment is: 10.5.2 (not server) 64 bit, php 5.2.5, apache 2.2.8.
After following the walkthrough, php in apache was indeed loaded with the gd library.
Hooray!
However, if I run php from the command line, I get:
——————————
dyld: NSLinkModule() error
dyld: Symbol not found: _php_sig_gif
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so
Expected in: dynamic lookup
Trace/BPT trap
——————————
Following the lead of Jeroen Mulder, I did every thing clean from /SourceCache/ — Previously, I too, had compiled from a different directory.
(I cleaned the source directories by simply untarring the sources again)
Unfortunately, nothing seems to have changed.
Anybody have any words of advice?
Is there somehow a difference between server and standard(?) 10.5?
Anything I can do to help somebody help me/us?
A short term workaround for the problem:
dyld: NSLinkModule() error
I copied my /etc/php.ini to a file called /etc/php.nogd.ini
I then reversed the php changes suggested by the walkthrough (reversed them in the _new_ php.nogd.ini).
————————–
; commented out the line:
; extension=gd.so
; put the following line back in:
extension_dir = “./”
————————–
After doing that you can sort of get your old command line php back?
By example, this should work now (should work without the new php.nogd.ini too):
php –no-php-ini –version
More importantly, this should now work:
php –php-ini /etc/php.nogd.ini yourscriptname.php
Obviously no gd support is there for the command line, but apache will have it.
Aside from this fugly workaround, I’d still be thankful for other advice.
The problem is that you’re supposed to compile php and gd together. So not all symbols are resolved.
mod_php5 contains those symbols, the php on the command line doesn’t
You need to fully recompile php doing the follow:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp ” CCFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch i386 -arch x86_64 -bind_at_load” ./configure –prefix=/usr –mandir=/usr/share/man –infodir=/usr/share/info –disable-dependency-tracking –with-apxs2=/usr/sbin/apxs –with-ldap=/usr –with-kerberos=/usr –enable-cli –with-zlib-dir=/usr –enable-trans-sid –with-xml –enable-exif –enable-ftp –enable-mbstring –enable-mbregex –enable-dbx –enable-sockets –with-iodbc=/usr –with-curl=/usr –with-config-file-path=/etc –sysconfdir=/etc –with-openssl –with-xmlrpc –with-xsl=/usr –without-pear –with-gd
make
sudo make install
Note that I do not compile for ppc nor ppc64, don’t need them, you may.
No more error on the command line.
For those requiring mysql compile mysql first using:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp ” CCFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch i386 -arch x86_64 -bind_at_load” ./configure –prefix=/usr/local/mysql –with-unix-socket-path=/usr/local/mysql/run/mysql_socket –with-mysqld-user=mysql –with-comment –with-debug
make
make install
then compile php 5.2.5 again with:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp ” CCFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch i386 -arch x86_64 -bind_at_load” ./configure –prefix=/usr –mandir=/usr/share/man –infodir=/usr/share/info –disable-dependency-tracking –with-apxs2=/usr/sbin/apxs –with-ldap=/usr –with-kerberos=/usr –enable-cli –with-zlib-dir=/usr –enable-trans-sid –with-xml –enable-exif –enable-ftp –enable-mbstring –enable-mbregex –enable-dbx –enable-sockets –with-iodbc=/usr –with-curl=/usr –with-config-file-path=/etc –sysconfdir=/etc –with-mysql-sock=/var/mysql –with-mysqli=/usr/bin/mysql_config –with-mysql=/usr/local/mysql –with-openssl –with-xmlrpc –with-xsl=/usr –without-pear –with-gd
I followed your directions, but it seems that the disabling of:
extension_dir = “./”
seems to have disabled all my other extensions like support for MySQL.
Any idea how to fix that?
Actually, now that I understand the php CLI does not have the image symbols, I realize that the apache plugin _is_ working.
The dual configurations (using php -c altphp.ini) is an acceptable solution in my env (I run regression tests with the CLI, so I don’t really need GD there).
Thanks!
I followed this guide, and it all seemed to work. But when I restarted apache I got: “PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0″. I checked the folder /usr/lib/php/extensions/no-debug-non-zts-20060613/ and found a gd.so that was not empty. Any ideas?
[...] GD ต่อโดยการลงก็ทำตามขั้นตอนใน Adding GD Library for Mac OS X Leopard (ลืมบอกไปผมใช้ MacOS X Leopard [...]
Great article and Great instructions. Thank you
A simpler solution to the CLI issue is make a php-cli.ini file with GD disabled and your command line PHP should work as expected. No recompile and Apache’s version of PHP has GD working.
CLI and php.ini extension errors: an easy solution that does not require a php.ini file with disabled extensions is to invoke
php -n
the -n option skips the php.ini file and works for example with bake.php of the cakephp framework.
sudo -s gives you a root terminal session until you type exit or quit. the step to enable root user is not necessary.
I had the same problem as almost everybody through these comments.. everything installed, nothing happened.
Apache error_log gave /usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so’ - (null) in Unknown on line 0, while PHP command line gave dyld: NSLinkModule() error
dyld: Symbol not found: _php_sig_gif
Referenced from: /SourceCache/php-5.2.4/ext/gd/modules/gd.so
Expected in: flat namespace.
I first installed everything on a first generation MacBook (i.e. 32-bit) then attempted on one of the new MacMinis (64-bit). The MacBook install worked on the first attempt, while the MacMini tok some attempts. After realizing it was a 64-bit, I gave it another try using the other instructions and sudo-ing every command.. No luck.
Doing a software update grabbing PHP-5.2.5, and using this source instead of the PHP-5.2.4, I decided to enable the sudo user through the Directory Utility’s Edit menu and logging in using sudo su. I followed the 64-bit instructions one last time, and it works like a charm:)
Great work guys!
Simply absolutely plain perfect
Thank you very very very much for this real time saver tutorial.
As someone already noticed that the shared library could not be produced for jpeg on some occasion, I solved it after struggled for days.
Here is how I got shared library for jpeg for OSX 10.5
tar -xzf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.* .
curl -o ltconfig http://www.finkproject.org/files/ltconfig
curl -o ltmain.sh h