Install GD for PHP on Mac OS X 10.5 Leopard


So, you need GD for your killer PHP web app, and you’re running Mac OS X 10.5? A quick look shows that GD doesn’t ship with Leopard. No worries. It’s pretty simple to install.

There are a few core requirements you must take care of before getting started. Choose to ignore these, and you’re doomed to failure!

  1. Always back up your system before a command-line activity such as this.
  2. Update your system to Mac OS 10.5.5. I could detail how to do this with prior versions, but I don’t have time.
  3. Install the latest version of Apple’s Developer Tools: XCode 3.0+ for 10.5. XCode is available on your OS X DVD, or from Apple as a free download.
  4. X11 must be installed (it is by default), as well as X11 SDK (from the Developer Tools in step 3).
DISCLAIMER: The author claims no responsibility for any damage that may occur from the use of any information found here or found on links followed from this document. If you choose to use this information, you do so at your own risk.

Get Started

To begin, open Terminal (Macintosh HD -> Applications -> Utilities ->Terminal) and invoke the superuser do command. You will need to enter your administrator password. Careful – you can now utterly destroy your machine:

sudo bash

You will need to enter your administrator password.

Determine Your Architecture

Mac OS X Leopard comes in two flavors, depending on the capabilities of your CPU — 32-bit or 64-bit. YOU MUST COMPILE FOR THE PROPER ARCHITECTURE.

Which architecture do you have? Easy enough using Terminal or the GUI. For Terminal, issue this command:

/usr/sbin/system_profiler SPHardwareDataType | grep "Processor Name:"

Or, in the GUI, choose the Apple Menu, select “About This Mac”:

The Core 2 Duo is a 64-bit CPU

Match your CPU to the table below:

Model 32-bit 64-bit
PowerPC G3 X
PowerPC G4 X
PowerPC G5 X
Intel Core Duo X
Intel Core2 Duo X
Intel Xeon X

 

Make a note of whether your CPU is 32-bit or 64-bit, because you will be compiling software using vastly different settings depending on your CPU.

Install libjpeg

The free image compression library, libjpeg, is required by GD.

First, let’s create a directory for storing the source files we’ll be downloading:

mkdir -p /SourceCache

cd /SourceCache

Download the source file and unpack it:

curl -O http://www.ijg.org/files/jpegsrc.v6b.tar.gz

tar xzpf jpegsrc.v6b.tar.gz

cd /SourceCache/jpeg-6b

cp /usr/share/libtool/config.sub .

cp /usr/share/libtool/config.guess .

Mac OS X Leopard comes in two flavors, depending on the capabilities of your CPU — 32-bit or 64-bit. YOU MUST COMPILE FOR THE PROPER ARCHITECTURE.

For 32-bit only, use the following command:

./configure --enable-shared

64-bit architecture uses this command instead:

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

Continue on for both architectures:

make clean

make

mkdir -p /usr/local/include

mkdir -p /usr/local/bin

mkdir -p /usr/local/lib

mkdir -p /usr/local/man/man1

make install

You now have compiled libjpeg!

Download and compile the GD graphics library extension (gd.so)

We will be using Apple’s Darwin sources for PHP, which interestingly contain the GD source code. Why Apple doesn’t ship with gd.so already compiled is known only to the maker.

mkdir -p /SourceCache

cd /SourceCache

curl -O http://www.opensource.apple.com/darwinsource/10.5.5/apache_mod_php-44.1/php-5.2.6.tar.bz2

tar xjf php-5.2.6.tar.bz2

cd /SourceCache/php-5.2.6/ext/gd

phpize

Again: YOU MUST COMPILE FOR THE PROPER ARCHITECTURE.

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

NOTE: Check the output of the last command. If you get an error similar to this –”/usr/X11/lib/libpng.3.0.0.dylib: No such file or directory” — you should create a symbolic link with a name matching the file referred to in the error message. For example, the above error indicates that no libpng.3.0.0.dylib file exists. Simply create a link named libpng.3.0.0.dylib pointing to libpng.3.dylib:           

sudo ln -s /usr/X11/lib/libpng.3.dylib /usr/X11/lib/libpng.3.0.0.dylib

Likewise, if your error refers to libpng12.0.##.#, you should create a symbolic link to libpng12.0.dylib.

Then, recompile GD.

 

Continue on for both architectures:

make clean

make

make install

Add gd.so to PHP

PHP needs to be configured to load the gd.so shared object extension that you just compiled. You will tell PHP to load it by adding a directive in your /etc/php.ini file.

First, let me give you a couple of pointers about this file. It *probably* exists on your machine. If not, you should just create it as a simple text file. Directives in the file can be commented out by placing a semi-colon in front of the directive.

Open the /etc/php.ini file in a text editor, and search for the section on Dynamic Extensions. Mine looks like this:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

Simply add the following line, which loads your newly compiled GD shared object:

extension=gd.so

Search your /etc/php.ini file for the  extension_dir= directive, and either comment it out (by inserting a semi-colon in front of it) or ensure it is pointing to the directory where your new GD shared object is stored:

extension_dir=/usr/lib/php/extensions/no-debug-non-zts-20060613

Confirm gd.so is loading

Restart Apache to force the reloading of the PHP configuration file.

apachectl graceful

Confirm that PHP is loading the gd.so extension by running the following command, and looking for the line “GD Support => enabled” in the resulting output:

/usr/bin/php -i|grep -i gd

Alternatively, you can create a file called phpinfo.php in your web server document directory (/Library/WebServer/Documents/) with the following contents:

<?php
phpinfo();
?>

Point your web browser to http://localhost/phpinfo.php, and you should see a GD block verifying installation, as shown below:

GD info block as it appears via phpinfo();

About this Piece O' Garbage

Join the fray by contributing trash, feeding on other people's trash, or linking to it from your dump.


Other Garbage Nearby

Talk Some Trash

Take a moment to submit some trash to this garbage pile. Some basic HTML is allowed for formatting.

Reader Trash in this Garbage Pile

Hi. Thanks for this tutorial, is exactly what I was searching for…

I have an error when inserting the 64-bit large command, after the “phpize”.

The error is this one:
“checking for jpeg_read_header in -ljpeg… no”
“configure: error: Problem with libjpeg.(a|so). Please check config.log for more information.”

Do you know which can be the problem?

Thank you in advance!

@Andreu: Go back and delete the /SourceCache/jpeg-6b/ directory, and redo your libjpeg installation. Something’s wrong there, which is causing the error you’re getting. Keep in mind you *must* compile both libjpeg and GD for the correct architecture: 64-bit or 32-bit.

Excellent write-up, thanks for sharing it!

The only wrinkle I ran into was the following error building the GD extension:

“i686-apple-darwin9-gcc-4.0.1: /usr/X11/lib/libpng.3.0.0.dylib: No such file or directory”

This is similar to the possible error you noted above, but for some reason, all I had in /usr/X11/lib were libpng12.0.26.0.dylib and libpng.3.26.0.dylib. There was no libpng12.0.24.0.dylib. Moreover, library_names in libpng.la referred to libpng.3.0.0.dylib, which didn’t even exist. However, libpng.3.26.0.dylib *did* exist, so I edited the linpng.la file to match, and GD finished building successfully.

libpng12.0.26.0.dylib also existed, but all things being equal, libpng.3.26.0.dylib seemed like the better choice (ie, what libpng.la may have actually intended).

I redo the installation of libjpeg and I have the same error than before. Any idea?

[...] Tuesday, October 28th, 2008 | Uncategorized | klalex Found a great article how to do this – Install GD for PHP on Mac OS X 10.5 Leopard. Thanks, Chris! Tags: Mac OS, [...]

All going fine until the last make command.
Getting the below errors also the files do exist in that location. Can I delete some directories to start over?
Also getting lipo: can’t figure out the architecture type… used the 64 bit since my about does say Core 2 Duo
Any ideas?
Cap

i686-apple-darwin9-gcc-4.0.1: powerpc-apple-darwin9-gcc-4.0.1: /usr/X11/lib/libpng.3.0.0.dylib: No such file or directory
/usr/X11/lib/libpng.3.0.0.dylib: No such file or directory
powerpc-apple-darwin9-gcc-4.0.1: /usr/X11/lib/libpng.3.0.0.dylib: No such file or directory
i686-apple-darwin9-gcc-4.0.1: /usr/X11/lib/libpng.3.0.0.dylib: No such file or directory
lipo: can’t figure out the architecture type of: /var/tmp//ccarkbQX.out

@Jeff: Curious. All the libpng.3.x.x.dylib files point to the same library. It’s not clear what updates or apps install the variously named versions of libpng. What version of OS 10.5 did you start with? I started with 10.5, and have installed each update through 10.5.5. A directory listing of /usr/X11/lib/ shows these version 3 files:

mbpro:usr cbrewer$ ls -al /usr/X11/lib/libpng.3*
/usr/X11/lib/libpng.3.0.0.dylib -> libpng.3.dylib
/usr/X11/lib/libpng.3.24.0.dylib -> libpng.3.dylib
/usr/X11/lib/libpng.3.26.0.dylib -> libpng.3.dylib
/usr/X11/lib/libpng.3.dylib

@CapRoberts: Are you sure that you have X11 SDK installed? You *must* have that installed. It is on the 10.5 installer DVD as part of the developer tools. Or you can download the developer tools from Apple for free.

What output do you get when entering the following:

lipo -info /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libpng.3.dylib

You should get:
Architectures in the fat file: /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libpng.3.dylib are: ppc7400 ppc64 i386 x86_64

You can safely delete the /SourceCache/jpeg-6b and /SourceCache/php-5.2.6/ directories and start over.

Hello Thanks for answering my question
I started out with OSX 10.5.5 but tried another install before this one I found on another site but that did not mention 32/64 bit differences and failed with the libpng12.0.24.0.dylib error.

I de and re installed the developer tools and X11

When entering: lipo -info /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libpng.3.dylib

I do get: Architectures in the fat file: /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libpng.3.dylib are: ppc7400 ppc64 i386 x86_64

Thank you so much for this great tutorial, everything worked unbelievably well.

Thanks for this great guide. I had the same issue as Jeff (comment 3), with X11 SDK installed, and got the same error. I started with OSX 10.5.4, updated to 10.5.5:

ls -al /usr/X11/lib/libpng.3*
/usr/X11/lib/libpng.3.24.0.dylib -> libpng.3.dylib
/usr/X11/lib/libpng.3.26.0.dylib -> libpng.3.dylib
/usr/X11/lib/libpng.3.dylib

@All with errors relating to libpng.3.0.0.dylib. I’ve updated the above instructions with a solution to the problem you’re reporting. I believe it to be the most elegant fix. Please let me and my readers know if it works out as such for you.

Try creating a link in /usr/X11/lib/ to the libpng.3.dylib file:

sudo ln -s /usr/X11/lib/libpng.3.dylib /usr/X11/lib/libpng.3.0.0.dylib

Then try compiling GD again.

That’s an elegant, functional solution. Thanks again.

This is good, other tutorials didn’t work for me on 64 bit Intel, 10.5.5 with PHP 5.2.6 but this one did.

The only problem I have is that the freetype support causes errors in the apache error_log.
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

there seems to be a solution using some files from fink/ macports, but it seems unclear.

Have you resolved this or even seen it?

Excellent! Worked without a hitch.
Thank you!

Thank you so much for this walkthrough, very, very good – THANKS!

Thank you so much for this. I tried another one I found online and got an error because it didnt account for the 32 vs 64 bit difference.

I know next to nothing about Terminal commands and just copied and pasted and thankfully it worked perfectly. You rock!

sudo ln -s /usr/X11/lib/libpng.3.dylib /usr/X11/lib/libpng.3.0.0.dylib

Thanks for the solution. Everything worked and the overall result is much better and faster then the entropy beta solution I was using in the mean time.

I have a very similar problem to Andreu from the 1st comment:

“configure: error: libjpeg.(a|so) not found.”

Please advise…

@Bob: See comment 2 onward. Follow step by step and it works.

Thank you! I did all this on Tiger a few years ago. Either I did it wrong back then or it was simply harder back then.

This was very easy thanks to your tutorial.

Hi Chris,

Great article. Thanks a lot for the time to write it and for the follow-up support to reader posts.

Rob

I’m getting this error when trying to do the 64 bit thing for libjpg:

checking whether the C compiler (gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load) works… no
configure: error: installation or configuration problem: C compiler cannot create executables.

I tried installing, and reinstalling xcode… any ideas?

I followed all the procedure, when i type
/usr/bin/php -i|grep -i gd
it show GD enabled but in phpinfo GD is not shown.

After several tests I added –with-gd to the configure command and it worked. Is it possible that you missed it? I don’t think so, so… what’s happened?

Francesco

I was having the same problem posted by Andreu in comment #1, despite carefully following all the steps. I think because my machine shipped with Leopard, perhaps I didn’t have some file hanging around this whole procedure expected. In any case, I found this post to allow libjpeg to be built and thus bypass the problem.

Thank you! I have been trying to get this working for the past day or so and your tutorial was exactly what I needed.

@Andreu and others with similar difficulties.

I installed the X11 SDK more times than I could count. Then I realized there was no X11.app in /Applications/Utilities/

I popped in the Leopard Installation DVD, opened up ‘Optional Installs.mpkg’ in the ‘Optional Installs’ Folder and installed X11. It would seem it is not installed by default.

Afterwards, I restarted this handy guide (thanks Chris) and everything worked fine.

Works great. Thank you!

Hi – thanks for this tutorial. I ran into this error:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/php_mysql.dll’ – (null) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/php_mysqli.dll’ – (null) in Unknown on line 0
PWD => /SourceCache/php-5.2.6/ext/gd
_SERVER["PWD"] => /SourceCache/php-5.2.6/ext/gd
_ENV["PWD"] => /SourceCache/php-5.2.6/ext/gd

Do you know what the problem is?

Thanks!

Thanks! Worked great!

@Ericka: Seems like your error is related to loading dll files, which is a Windows process. If you’re trying to follow these directions on a Windows box, you’re sure to fail. Conversely, if you’re trying to load DLLs on your Mac, you will also fail.

Thanks for your help! This proved extremely easy to implement!

“If the screen says Core Duo, you’re 32-bit. Anything else, and you’re running 64-bit. My MacBook Pro is running 64-bit because of the Core 2 Duo:”

Should this say that a Core Duo is 64 bit and anything else is 32? I complied for PPC in 32 bit and it worked great. Great post thanks.

Thanks for the tutorial. I believe I have everything installed correctly; when I type:
/usr/bin/php -i|grep -i gd
I get:
gd
GD Support => enabled
GD Version => bundled (2.0.34 compatible)

Yet the gd block is not showing up in my phpinfo file. I have no idea why this is happening. Any help would be greatly appreciated.

The answer to my question above is that I compiled using 32bit when I should have used 64bit. Who woulda thunk that a PPC G5 PowerMac is 64bit… Thanks so much!

Excellent tutorial! Thank you.

Had one problem with the original file at the end of the jpeglib download http. It wouldn’t unpack and seemed really small (4kb). I found the FTP site for the jpeglib (see: http://www.linuxfromscratch.org/blfs/view/svn/general/libjpeg.html) and ftp’d the file to the SourceCache folder, unpacked it and voila, worked like a charm.

Ok, I can’t get it to work, I have a 64 bit machine (dual 2.3ghz power pc) running 10.5.6 server.

Here is what I get as an error and how I’ve aliased the files as requested.

Can anyone see what I’ve done wrong?

-GReg

checking for jpeg_read_header in -ljpeg… yes
configure: error: libpng.(a|so) not found.

bash-3.2# ls -al /usr/X11/lib/libpng.3*
lrwxr-xr-x 1 root wheel 27 Jan 26 21:36 /usr/X11/lib/libpng.3.0.0.dylib -> /usr/X11/lib/libpng.3.dylib
lrwxr-xr-x 1 root wheel 27 Jan 26 21:42 /usr/X11/lib/libpng.3.24.0.dylib -> /usr/X11/lib/libpng.3.dylib
lrwxr-xr-x 1 root wheel 14 Jan 17 12:22 /usr/X11/lib/libpng.3.26.0.dylib -> libpng.3.dylib
-rwxr-xr-x 1 root wheel 687936 Jul 31 21:57 /usr/X11/lib/libpng.3.dylib

Just Perfect .. thanx.

Awesome — thanks!!!

Gee thanks, great additions to the other guides.

I was so frustrated with getting GD to work.I have spent 3 days in a very hot room working on this. There’s alot of misleading information on the web about this topic – most of it for windows – but this tutorial hit the spot. Thanks a million!
It didn’t work the first time, but I persisted with it and – bingo. Great work.Joy.
Oh! And did I thank you?

Excellent tutorial, can’t thank you enough for this. I tried Entropy to get GD but that went wrong somewhere and was afraid I was going to have to delve into code to sort it out. This tutorial was a life saver and very easy to follow.

I did have one small stumble; when I restarted apache, php didn’t load and the error log showed “PHP Startup: Unable to load dynamic library ‘./gd.so’ – (null) in Unknown on line 0″. Turns out I forgot to uncomment the extension_dir= line in php.ini. Restarting apache a couple of times after that seemed to fix it.

I was skeptical as I’ve spent all day looking and trying different solutions to get gd installed.

This worked flawlessly the first time and only took about 15 minutes!

You rock!

Hi. This worked great for me! Except for one thing. After this step i got:
/usr/bin/php -i|grep -i gd
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

So I did this:
cd /SourceCache/php-5.2.6/ext/gd/modules
cp gd.so /usr/lib/php/extensions/no-debug-non-zts-20060613

After which I re-ran and got:
/usr/bin/php -i|grep -i gd
gd
GD Support => enabled
GD Version => bundled (2.0.34 compatible)

And restarting apache shows gd installed.

Anybody else run into this?

Thanks for a great tutorial!

Mate you rock thanks a mill for the clear concise instructions, i can stop pulling out my hair now

I tried this once and the info.php did not change. Compile date was showing Sept 2008 and no GD or BCMath was enabled. I am going back to the cloned drive and trying again. Do I have to point Apache to anyplace different after this process is done? The tutorial doesn’t say.

@Curator: When you say “compile date”, to what file are you referring?

@ALL: I’ve updated the post with a table on CPUs, and clarified the php.ini portion.

I guess I mean Build Date as shown in the info.php just above Configure Command.

And also do I do anything with /etc/apache2/httpd.conf

Do I need to point it anywhere else?

Do I do anything with the LoadModule php5_module line?

SourceCache is just where I download all the stuff but will it be the place where PHP now runs from?

@Curator: The build date is for the PHP binary, which you are not recompiling, so it won’t change.

So long as Apache is configured to run PHP (which it is if you’re getting output from phpinfo.php), you shouldn’t need to alter the httpd.conf file. The newly edited instructions explain how to point to the newly compiled gd.so in your /etc/php.conf file using the extension_dir directive. That same directive reveals where the gd.so file is stored.

How do I include enabling bcmath to this compile for a 64-bit, and ensuring all the other built-in libraries are enabled? ldap, openssl, http://ftp... all the other stuff?

This is what I am ending up with.

PWD => /SourceCache/php-5.2.6/ext/gd
_SERVER["PWD"] => /SourceCache/php-5.2.6/ext/gd
_ENV["PWD"] => /SourceCache/php-5.2.6/ext/gd

Perry Jeung (#43), your comment was most helpful of all! I had the same problem and your solution fixed it.

Worked a treat on OSX 10.5.6 and 10.5.6 Server. Thanks!

Thanks !

Its guide is very well !!

congratulations.

Hi Chris Brewer, I have tried and tried and tried many time over and carefully going back throughly but I keep getting the error posted like no. 1 by Andreu and followed your answer on no. 2 to no avail. I have mac os x 10.5.6 with 64 bit. Please help!
Thank you

Oh, I got it to work just fine, it was my bad! the instruction is perfect, it was my bad jumping the gun early. I wanted everyone to know, if you’all take a little step back re-read the instruction, it’s exactly just that! It’s working very nice, Thank you Chris for posting this, YOU’re the man!

This worked great! Thanks for the write-up!

Hey. Thanks for the tutorial. Worked great. I didn’t see the need for the -p in mkdir, though. Also, your cd instructions after the untarring looked over the fact that you are already inside the SourceCache folder. Those were my only gripes, and quite minor at that. :D

I’ve followed your instructions 3x, copy/pasting commands where necessary and GD isn’t being loaded into PHP. I am using OS X 10.5.6.

I changed the php source path to reflect 10.5.6 instead of 10.5.5, but other than that there is no change between the PHP versions.

When I run “/usr/bin/php -i|grep -i gd” it shows GD is enabled:
gd
GD Support => enabled
GD Version => bundled (2.0.34 compatible)

However phpinfo() doesn’t show anything for GD after restarting apache

Hi,

I have the same issue as Francesco #23.

When I do the command /usr/bin/php -i|grep -i gd it shows:

GD Support => enabled
GD Version => bundled (2.0.34 compatible)

However in a phpinfo(); page in php it doesn’t have the GD Image bit on that PHP info page.

Can someone help me?

The tutorial worked great. I had an error at first, but I followed the advice to @bob, and went back and recompiled libjpeg (and followed ALL the steps this time) and it worked great! Thanks!

Worked on the first try, no errors, took maybe five minutes. Thanks a million!

[Idea: turn this guide into a more general guide that would also include extending Mac OS X's built-in PHP with other extensions that aren't installed by default (not just GD). Seems to be a good foundation for this.]

I’m having difficulty writing out the modified php.ini file in /etc It is write protected and I cannot use chmod to change the permissions on etc

Is there more than one /etc directory? Did I overlook something?

Chris

@Chris: Hi. There can only be one /etc/ directory. The php.ini file is write protected, insofar as you need to have admin permissions to edit it. This is accomplished by issuing the “sudo bash” command as illustrated in the instructions. BE CAREFUL. Once you issue that command, you are able to completely destroy your OS installation. I wouldn’t recommend futzing with ownership and permissions of the /etc/ directory.

Great tute Chris, thorough and enormously helpful.

Excellent tute, worked first time.
A++ would buy from again.

Thanks chris, great stuff here.
I ran into the following problem for the GD extension. At the command tar xjf php-5.2.6.tar.bz2 it wouldn’t untar for some reason. After several tries, I had to go the source file on apple site (http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-44.1/)and download the 5.2.6.tar.bz2 there, then move it to the SourceCache folder, then proceed.
Everything then worked as expected.
Note, I have OSX 10.5.7 and PHP 5.2.8 installed (new IMac), so it might be the reason of my problem. Hope it might help someone out there.

Anyway, thanks again
stephane

Thank you very much.
Excellent post, easy to follow.
Well done!!

Regards,
V

[...] So I made the decision to just recompile PHP with GD Support. After a few hours, I began to think that this was not a good decision. I was following the step-by-step instructions that I found here. [...]

you’re da man! – 1 thing that may help others: i got the error in your NOTE only when doing the make install. creating the link as per your NOTE and then redoing the make install solved things for me. thanks a million.

I have run into a few problems with the process in the article. I suspect it is a versioning problem but I’ve not been able to resolve it yet. Here are the problems I’ve found. For reference I am running OS 10.5.7 and php ver 5.2.8.

1. In the “Download and compile the CD raphics library extension” part following the command: tar xjf php-5.2.6.tar.bz2 I get an error essage “tar: Error ….bzip2: (stdin) in not a bpzip2 file.
I tried downloading it three times with the same result. I placed the URL in my browser and downloaded the file into a different location, then double clicked the file in the Mac window mode and it decompressed the files for me. Not sure what is happening here(currently corrupted file at the source?(, but my workaround seemed to work ok. (unless item 2 below is the resulting problem).

2. In the same section following the 64-bit use: with partial coding: MACOSX_DEPLOYMENT_TARGET…
following the output, I get an error message similar to /usr/x11/lib/libpng.3.0.0.dylib:
No such file or directory.” In trying to create a symbolic link to the file, as you suggested,
I noted that the file simply does not exist on my computer. Instead I see the files:
/usr/xll/lib/libpng.3.24.dylib, (also the files libpng.3.26.dylib and libpng.3.35.dylib). So
creating a symbolic link probably won’t work because somewhere the program is looking for the 3.0.0 version of the file. Any suggestions as to how I modify the process to accept the newer version? Or am I just stuck in version hell and unable to make it work? (or just not smart enough to figure it out?

@Dick,

It sounds like there is a corrupt source file. In any event, Mac OS X has been updated several times since this article was written, with changes to the PHP version. You need to download the matching version of PHP source: 5.2.8 per your message. It’s at http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-44.2/php-5.2.8.tar.bz2. Also, try using curl as I detailed in the instructions instead of downloading it with your browser.

When I run the following command on my 10.5.7 system, here’s what I see regarding libpng libraries:

ls -al /usr/x11/lib/libpng*

lrwxr-xr-x 1 root wheel 14 Jan 28 2008 /usr/x11/lib/libpng.3.0.0.dylib -> libpng.3.dylib
lrwxr-xr-x 1 root wheel 14 Mar 19 2008 /usr/x11/lib/libpng.3.24.0.dylib -> libpng.3.dylib
lrwxr-xr-x 1 root wheel 14 Dec 15 2008 /usr/x11/lib/libpng.3.26.0.dylib -> libpng.3.dylib
lrwxr-xr-x 1 root wheel 14 May 13 10:15 /usr/x11/lib/libpng.3.35.0.dylib -> libpng.3.dylib
-rwxr-xr-x 1 root wheel 684000 Mar 12 20:38 /usr/x11/lib/libpng.3.dylib
lrwxr-xr-x 1 root wheel 14 Mar 19 2008 /usr/x11/lib/libpng.dylib -> libpng12.dylib
-rwxr-xr-x 1 root wheel 834 Feb 27 2008 /usr/x11/lib/libpng.la
lrwxr-xr-x 1 root wheel 16 Jan 28 2008 /usr/x11/lib/libpng12.0.0.0.dylib -> libpng12.0.dylib
lrwxr-xr-x 1 root wheel 16 Mar 19 2008 /usr/x11/lib/libpng12.0.24.0.dylib -> libpng12.0.dylib
lrwxr-xr-x 1 root wheel 16 Dec 15 2008 /usr/x11/lib/libpng12.0.26.0.dylib -> libpng12.0.dylib
lrwxr-xr-x 1 root wheel 16 May 13 10:15 /usr/x11/lib/libpng12.0.35.0.dylib -> libpng12.0.dylib
-rwxr-xr-x 1 root wheel 684000 Mar 12 20:38 /usr/x11/lib/libpng12.0.dylib
lrwxr-xr-x 1 root wheel 16 Jan 28 2008 /usr/x11/lib/libpng12.dylib -> libpng12.0.dylib
-rwxr-xr-x 1 root wheel 834 Feb 27 2008 /usr/x11/lib/libpng12.la

What this directory listing shows is that Apple is creating new static links to /usr/x11/lib/libpng.3.dylib each time a new OS patch is released. Thus in my directory listing you see libpng.3.0.0.dylib, libpng.3.24.0.dylib, libpng.3.26.0.dylib, and finally libpng.3.35.0.dylib, all pointing to the same file.

Why is this important? Because all those versions point to the latest version installed, which is always the libpng.3.dylib file. Thus, my instructions are to create a link to the libpng3.dylib file with a name that matches whatever file the error message indicates. For example, if your error message is complaining that it can’t find libpng.3.0.XX.dylib, the create a static link thus:

sudo ln -s /usr/X11/lib/libpng.3.dylib /usr/X11/lib/libpng.3.0.XX.dylib

Hope that helps!

Thanks a bunch for the great help. Your suggestion did the trick!. Great blogs!

Dick

Great tutorial!

However, I encountered the same problem as Francesco in #24, but configuring with the option “–with-gd” did not seem to make a difference for me, and the GD block still does not appear with phpinfo, though I do receive the correct response from the command line showing the GD is installed.

Anyone have any ideas?

The php version today and jpegsrc are both updated. This tutorial will not work anymore, at list for dummies like me…

With 64-bit architecture, to compile the current release of libjpeg (version 7), add the option –disable-dependency-tracking to the configure command :

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 --disable-dependency-tracking

This is one way to fix the GCC compilation error : “gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags

for GD compilation, nothing change…

Hallo, Thanks a lot for this tutorial. I found it really good.
One thing during the “Install libjpeg configuration” for 64 bits, I had this problem:
bash-3.2# make
make all-am
CC jaricom.lo
gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
make[1]: *** [jaricom.lo] Error 1
make: *** [all] Error 2

This can be solve by adding to the configuration:
–disable-dependency-tracking

so then we have 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 –disable-dependency-tracking

Thanks a lot.

if you get this error at the fist make:
make[1]: *** [jaricom.lo] Error 1
make: *** [all] Error 2

then you might want to use this for the first 64-bit-only command:
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 –disable-dependency-tracking

the only thing added to that command is –disable-dependency-tracking

When I try to run the make command for libjpeg (64 bit architecture) I get the following error

make all-am
CC jaricom.lo
gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
make[1]: *** [jaricom.lo] Error 1
make: *** [all] Error 2

bit stumped with this one.

PS jpeg-6b is gone now – I’m using jpeg-7

Cheers

If your libjpeg installation isn’t working try this for the build

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 –disable-dependency-tracking