Can't get PHP with GD / libjpeg to work

I'm totally frustrated, I tried compiling PHP 5.2.6 with GD and JPEG/PNG support on my Dual 2 GHz PowerPC G5 since yesterday (installed the latest XCode version) but without success so far. I also did all necessary steps like recompiling apache2, libjpeg and libpng. I found lots of tutorials but none of them worked out. PNG support works fine, here's the info from phpinfo()

GD Support enabled
GD Version bundled (2.0.34 compatible)
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

But whenever I use --with-jpeg-dir=/usr/local/lib /that's the dir I compiled libjpeg to) when configuring php I get the following errors when executing the "make" command:


lt -liconv -liodbc -lmysqlclient -lldap -llber -liconv -liconv -lfreetype -lX11 -lXpm -lpng -lz -ljpeg -lssl -lcrypto -lcurl -lz -lssl -lcrypto -lm -lxml2 -lz -licucore -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lssl -lcrypto -lz -lxml2 -lz -licucore -lm -lmysqlclient -lz -lm -liodbc -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxslt -lxml2 -lz -licucore -lm -o libs/libphp5.bundle && cp libs/libphp5.bundle libs/libphp5.so
Undefined symbols:
"_jpeg_destroy_compress", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_resync_to_restart", referenced from:
_jpeg_resync_to_restart$non_lazy_ptr in gd_jpeg.o
"_jpeg_start_compress", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_CreateDecompress", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_set_defaults", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_destroy", referenced from:
_fatal_jpeg_error in gd_jpeg.o
"_jpeg_destroy_decompress", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_write_marker", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_finish_decompress", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_std_error", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_read_header", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_set_quality", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_finish_compress", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_write_scanlines", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_start_decompress", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_CreateCompress", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
"_jpeg_read_scanlines", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_save_markers", referenced from:
_php_gd_gdImageCreateFromJpegCtx in gd_jpeg.o
"_jpeg_simple_progression", referenced from:
_php_gd_gdImageJpegCtx in gd_jpeg.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1


Can anyone help me? Maybe I need special CFLAGS for my machine? Thanks in advance.

Dual 2 GHz PowerPC G5, Mac OS X (10.5.4)

Posted on Aug 17, 2008 5:22 AM

Reply
7 replies

Aug 19, 2008 12:16 AM in response to etresoft

I got the jpeg source files from http://www.ijg.org/files/and compiled it according to some tutorials I found on the net. I also installed it using the port command (used --with-jpeg-dir=/opt/local for php then), but whatever I did and whatever configuration I used I always get the same error.

Tried it with
env MACOSX DEPLOYMENTTARGET=10.5 CFLAGS="-O -g -arch ppc -arch i386" LDFLAGS="-arch ppc -arch i386"
./configure -prefix=/usr -sysconfdir=/etc -localstatedir=/var -mandir=/usr/share/man -disable-dependency-tracking

and without the env command as well

then
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a

Maybe someone can post me the correct configure command for compiling libjpeg including the environment vars (CFLAGS and whatever) I need for my machine (Dual 2 GHz PowerPC G5). Thanks!

Aug 19, 2008 7:37 AM in response to Rob-C

Rob-C wrote:
I got the jpeg source files from http://www.ijg.org/files/and compiled it according to some tutorials I found on the net. I also installed it using the port command (used --with-jpeg-dir=/opt/local for php then), but whatever I did and whatever configuration I used I always get the same error.


/opt huh? Why am I not surprised? Your first step should be to purge all traces of whatever "port" software you were using and delete any software you installed with it. If you don't want to do that, you'll have to contact them (fink or MacPorts/DarwinPorts or whatever they are now) for support. The port packages do work and seem to work well for the software they provide. The evidence I have seen indicates that if they don't provide the port, it won't work. Be prepared for very strange and unsolvable problems when compiling non-ports software using ports tools. Plus, you can't really ask for help from the non-ports community, because all that non-ports software works fine for us.

PS: Sorry if I sound a bit harsh. I've just seen too many of these postings. At least I have located the culprit - Apple!. That information is over five years old. I'm going to file a bug report against it.

But I will try to help with what I can for now...

Tried it with
env MACOSX DEPLOYMENTTARGET=10.5 CFLAGS="-O -g -arch ppc -arch i386" LDFLAGS="-arch ppc -arch i386"
./configure -prefix=/usr -sysconfdir=/etc -localstatedir=/var -mandir=/usr/share/man -disable-dependency-tracking

and without the env command as well


Unless you are distributing the software, you shouldn't need to include the cross compilation options. However, when linking several of these projects together (as in PHP) you do need to match the compilation options for all the code that is linked together. Use whatever settings you used when you built PHP.

then
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a


It seems that libjpeg hasn't been updated in 10 years, so these instructions look OK, more or less. Try "--disable-static" instead of "--enable-static". If that fails, leave them both off and try to link against the default static libraries.

Aug 20, 2008 1:13 AM in response to Rob-C

Ok now I found the problem. When compiling php is was using --with-apxs2=/usr/sbin/apxs which ended up in that error. When I use --with-apxs2=/usr/local/apache2/bin/apxs (my own apache compilation) compiling php throws no jpeg-errors.

Now my final question: can anyone give me a short tutorial what to do to make my own apache compilation the standard compilation that automatically starts up when I startup my mac?

Thx!

Aug 22, 2008 10:18 AM in response to Rob-C

No end of my problem unfortunately 😟 After recompiling apache, jpeg (tried both way with "--enable-static --enable-shared", "--disable-static --enable-shared), png and php again I still get the above mentioned error message. I'm really desperate now.

Are there any special options I should use when compiling apache? As I already said, comiling php with jpeg but without the -apxs option works. But whenever I use the apxs option (and I checked the path to the apxs-file) it fails.

Can someone post a way (with examples) how to compile these tools correctly, including options I should try? I have a Dual 2 GHz PowerPC G5 (PowerPC 970 processor). Please help!

Aug 23, 2008 2:34 AM in response to Rob-C

Finally it worked!!! I recomplied the all the packages (apache, libjpeg, libpng, gd-lib and php) as follows:

==================================
APACHE
==================================
./configure --enable-layout=Darwin --enable-mods-shared=all
make
sudo make install


==================================
JPEG
==================================
First I changed to the gdlib directory and used did
cd /tmp/gd-2.0.35
./configure --with-jpeg=/usr/local

afterwards I copied the libtool from the gd-library to the jpeg-6b directory.

cd /tmp/jpeg-6b
cp /tmp/gd-2.0.35/libtool .
export MACOSX DEPLOYMENTTARGET=10.5
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --disable-static
make
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/lib
mkdir -p /usr/local/man/man1
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a


==================================
PNG
==================================
cd /tmp/libpng-1.2.30
export MACOSX DEPLOYMENTTARGET=10.5
./configure
make
sudo make install
sudo ranlib /usr/local/lib/libpng.a


==================================
GD
==================================
cd /tmp/gd-2.0.35
./configure --with-jpeg=/usr/local
make
sudo make install


==================================
PHP
==================================

cd /tmp/php-5.2.6
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--enable-ftp \
--enable-exif \
--enable-sockets \
--enable-mbregex \
--enable-mbstring=all \
--with-curl \
--with-apxs2=/usr/sbin/apxs \
--with-zlib-dir=/usr \
--with-zlib \
--with-gd=/usr/local \
--with-jpeg-dir=/usr/local \
--with-freetype-dir=/usr/X11R6 \
--with-mysql=/usr/local/mysql
make
sudo make install

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't get PHP with GD / libjpeg to work

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.