AFP548

PHP5, libjpeg (for GD2), 10.5 Server

OK, I'm totally frustrated now. I'm trying to build PHP5 as a universal binary (hence all the -arch switches below) so I don't have to worry about what Apache2 wants to load. When building libjpeg, I can't get both shared libraries and multiple architectures to happen at the same time. Here's what happens: [code] shr-g5:jpeg-6b admin$ 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 checking for gcc... gcc 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... yes 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) is a cross-compiler... no checking whether we are using GNU C... yes checking how to run the C preprocessor... gcc -E checking for function prototypes... yes checking for stddef.h... yes checking for stdlib.h... yes checking for string.h... yes checking for size_t... yes checking for type unsigned char... yes checking for type unsigned short... yes checking for type void... yes checking for working const... yes checking for inline... __inline__ checking for broken incomplete types... ok checking for short external names... ok checking to see if char is signed... yes checking to see if right shift is signed... yes checking to see if fopen accepts b spec... yes checking for a BSD compatible install... /usr/bin/install -c checking for ranlib... ranlib checking host system type... powerpc-apple-darwin9.1.0 checking for ranlib... ranlib checking for gcc... gcc checking whether we are using GNU C... yes checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc static flag -static works... none checking whether ln -s works... yes checking for ld used by GCC... /usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/ld checking if the linker (/usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/ld) is GNU ld... no checking whether the linker (/usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/ld) supports shared libraries... no checking for BSD-compatible nm... /usr/bin/nm -p checking command to parse /usr/bin/nm -p output... no checking how to hardcode library paths into programs... unsupported checking for /usr/libexec/gcc/powerpc-apple-darwin9/4.0.1/ld option to reload object files... -r checking dynamic linker characteristics... no checking if libtool supports shared libraries... no checking whether to build shared libraries... no checking whether to build static libraries... yes checking for objdir... .libs creating libtool checking libjpeg version number... 62 creating ./config.status creating Makefile creating jconfig.h [/code] Note that ltconfig thinks it can't make the dynamic libraries. Anyway, make results in... [code] shr-g5:jpeg-6b admin$ make ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapimin.c gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapimin.c echo timestamp > jcapimin.lo ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapistd.c gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapistd.c echo timestamp > jcapistd.lo 8 jmemnobs.lo ./libtool --mode=link gcc -o libjpeg.la jcapimin.lo jcapistd.lo jctrans.lo jcparam.lo jdatadst.lo jcinit.lo jcmaster.lo jcmarker.lo jcmainct.lo jcprepct.lo jccoefct.lo jccolor.lo jcsample.lo jchuff.lo jcphuff.lo jcdctmgr.lo jfdctfst.lo jfdctflt.lo jfdctint.lo jdapimin.lo jdapistd.lo jdtrans.lo jdatasrc.lo jdmaster.lo jdinput.lo jdmarker.lo jdhuff.lo jdphuff.lo jdmainct.lo jdcoefct.lo jdpostct.lo jddctmgr.lo jidctfst.lo jidctflt.lo jidctint.lo jidctred.lo jdsample.lo jdcolor.lo jquant1.lo jquant2.lo jdmerge.lo jcomapi.lo jutils.lo jerror.lo jmemmgr.lo jmemnobs.lo \ -rpath /usr/local/lib -version-info 62 mkdir .libs ar cru .libs/libjpeg.a jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o jfdctint.o jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o jcomapi.o jutils.o jerror.o jmemmgr.o jmemnobs.o ranlib .libs/libjpeg.a creating libjpeg.la (cd .libs && ln -s ../libjpeg.la libjpeg.la) ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./cjpeg.c gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./cjpeg.c echo timestamp > cjpeg.lo ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./rdppm.c 8 cdjpeg.lo ./libtool --mode=link gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o cjpeg cjpeg.lo rdppm.lo rdgif.lo rdtarga.lo rdrle.lo rdbmp.lo rdswitch.lo cdjpeg.lo libjpeg.la gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o cjpeg cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o cdjpeg.o .libs/libjpeg.a ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./djpeg.c gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./djpeg.c echo timestamp > djpeg.lo 8 rdcolmap.lo ./libtool --mode=link gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o djpeg djpeg.lo wrppm.lo wrgif.lo wrtarga.lo wrrle.lo wrbmp.lo rdcolmap.lo cdjpeg.lo libjpeg.la gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o djpeg djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o cdjpeg.o .libs/libjpeg.a ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jpegtran.c gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jpegtran.c echo timestamp > jpegtran.lo 8 wrjpgcom.lo ./libtool --mode=link gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o wrjpgcom wrjpgcom.lo gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load -o wrjpgcom wrjpgcom.o [/code] !! Finally !! Time to make install [code] shr-g5:jpeg-6b admin$ sudo make install Password: /usr/bin/install -c -m 644 jconfig.h /usr/local/include/jconfig.h /usr/bin/install -c -m 644 ./jpeglib.h /usr/local/include/jpeglib.h /usr/bin/install -c -m 644 ./jmorecfg.h /usr/local/include/jmorecfg.h /usr/bin/install -c -m 644 ./jerror.h /usr/local/include/jerror.h ./libtool --mode=install /usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la /usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la /usr/bin/install -c .libs/libjpeg.a /usr/local/lib/libjpeg.a ranlib /usr/local/lib/libjpeg.a chmod 644 /usr/local/lib/libjpeg.a Libraries have been installed in: /usr/local/lib To link against installed libraries in a given directory, LIBDIR, you must use the `-LLIBDIR' flag during linking. You will also need to do one of the following: See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ./libtool --mode=install /usr/bin/install -c cjpeg /usr/local/bin/cjpeg /usr/bin/install -c cjpeg /usr/local/bin/cjpeg ./libtool --mode=install /usr/bin/install -c djpeg /usr/local/bin/djpeg /usr/bin/install -c djpeg /usr/local/bin/djpeg ./libtool --mode=install /usr/bin/install -c jpegtran /usr/local/bin/jpegtran /usr/bin/install -c jpegtran /usr/local/bin/jpegtran ./libtool --mode=install /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom ./libtool --mode=install /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/man/man1/cjpeg.1 /usr/bin/install -c -m 644 ./djpeg.1 /usr/local/man/man1/djpeg.1 /usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/man/man1/jpegtran.1 /usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/man/man1/rdjpgcom.1 /usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/man/man1/wrjpgcom.1 [/code] As you can see, only the static libraries are built. Well, what do we do about that?! According to a tip found in an AFP548 article, the libtool that comes with libjpeg is out of date, so it recommends copying a version from the gd source. (See https://www.afp548.com/article.php?story=20041104230209410&mode=print.) I'll make a long story shorter: if I copy libtool over after the ./configure of above, I do manage to get twice as much compiling going on, like this sample shows: [code] ./libtool --mode=compile gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapimin.c mkdir .libs gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapimin.c -fno-common -DPIC -o .libs/jcapimin.o gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -I. -c ./jcapimin.c -o jcapimin.o >/dev/null 2>&1 [/code] But it ends, Alas! in failure, as this sample shows: [code] ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status collect2: ld returned 1 exit status ld: warning in ./.libs/libjpeg.dylib, file is not of required architecture Undefined symbols for architecture x86_64: [/code] OK, what happens if I copy libtool over before the ./configure? (Funny you should ask...) No changes to jconfig.h, and libtool is overwritten, so that doesn't make any difference. Somehow, I accidentally managed to discover that if I issue a plain old ./configure --enable-shared --enable-static and then copy over the libtool from gd, I manage to get dylibs! But they don't contain enough architectures, because PHP's configure gripes, as always, with this: [code] configure:37492: gcc -o conftest -O -g -arch i386 -arch ppc -arch ppc64 -arch x86_64 -pipe -no-cpp-precomp -no-cpp-precomp -Wl,-rpath,/usr/local/lib -L/usr/local/lib -arch i386 -arch ppc -arch ppc64 -arch x86_64 -bind_at_load co nftest.c -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 1>&5 ld: warning in /usr/local/lib/libjpeg.dylib, file is not of required architecture Undefined symbols for architecture x86_64: "_jpeg_read_header", referenced from: _main in ccW5jAeh.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status ld: warning in /usr/local/lib/libjpeg.dylib, file is not of required architecture Undefined symbols for architecture i386: "_jpeg_read_header", referenced from: _main in cceN0mpf.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status ld: warning in /usr/local/lib/libjpeg.dylib, file is not of required architecture Undefined symbols for architecture ppc64: "_jpeg_read_header", referenced from: _main in ccO23NVJ.o ld: symbol(s) not found for architecture ppc64 collect2: ld returned 1 exit status lipo: can't open input file: /var/tmp//cceEaa65.out (No such file or directory) configure: failed program was: #line 37481 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char jpeg_read_header(); int main() { jpeg_read_header() ; return 0; } [/code] (The above came from php/config.log.) [b]BOTTOM LINE[/b] Obviously, I want everything: I want a libjpeg compiled for all four architectures (since that's what I'm doing with PHP), and I want it to be a dynamic library, too. That's the bottom line. Can anybody help?! /Bill
Exit mobile version