How to install GD2 Library ?

Hello,
does anyone know a tutorial to install the gd2 library on leopard server?

the tutorial from http://osx.topicdesk.com/ is not working properly.

Is it necessary to recompile php 5.2.4 which is shipped with leo server?

many questions here

chico

Various, Mac OS X (10.5)

Posted on Nov 6, 2007 8:12 AM

Reply
37 replies

Nov 6, 2007 9:55 AM in response to Chico11mbit

Before rebuilding PHP you must get the GD Libraries to install. You have yet to say what problems you had.

After having installed the GD Library, you can use the PHP instructions for 10.4.x found in the same place (but you will need to change a few things).

Look for the PHP5 section. Use the instructions, but use XCode 3 and replace the configuration string with:
./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=/private/etc --with-mysql-sock=/var/mysql --with-mysqli=/usr/bin/mysql_config --with-mysql=/usr --with-openssl --with-xmlrpc --with-xsl=/usr --without-pear --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/X11R6 --with-gd=/usr/local

Friendly advice: No offence meant, but if this is over your head, have somebody else do this for you. You can mess up your system.

Nov 7, 2007 11:39 PM in response to Frederic Dran

Follow the tutorial at http://www.veola.net/macintosh/adding-gd-library-for-mac-os-x-leopard



This an almost literal transcription of my instructions on building the GD Graphic Library on Mac OS X. At least they had the decency to mention that they looked up the tutorial on topicdesk.com.

Unfortunately, they 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 on Leopard. 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'd 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.

We will release thoroughly tested instructions on integrating GD into PHP soon.

Alex

Nov 8, 2007 7:38 AM in response to pterobyte

I have now added the tutorial on Adding the GD Extension to PHP5 on OS X Server 10.5.x to my site.

It takes into account what is and isn't already installed with Mac OS X Server 10.5 and Developer Tools 3.0 and will guide you through enabling GD for PHP5 without tampering with Apple's default installation. Only modules not already present will be added to avoid duplicate libraries and resulting issues.

HTH,
Alex

Nov 11, 2007 11:59 AM in response to pterobyte

I am trying to setup GD with the default PHP build that comes preinstalled on Leopard, but I am unable to get it work correctly.

So far I have followed these instructions to get PHP5 working with with Apache2, this works fine and I am able to setup multiple virtual hosts for each of my websites and I have also downloaded and installed MySQL 5.0.45 which is now working fine with PHP the only problem is trying to get the extensions working.

I then tried following: Add the GD Extension to PHP5 on OS X Server 10.5.x guide to install GD2, which all seemed to work in the terminal, but after I restarted Apache and reloaded my phpinfo() there is still no mention of GD.

Any ideas why it isn't working (PS I have installed Xcode and X11SDK, from the Leopard DVD)

Heres my terminal log:

<pre>Last login: Sun Nov 11 18:59:13 on ttys000
Sebs-Mac-Mini:~ Seb$ cd /SourceCache/jpeg-6b
Sebs-Mac-Mini:jpeg-6b Seb$ sudo cp /usr/share/libtool/config.sub .
Password:
Sebs-Mac-Mini:jpeg-6b Seb$ sudo cp /usr/share/libtool/config.guess .
Sebs-Mac-Mini:jpeg-6b Seb$ sudo ./configure --enable-shared
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) 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... i686-apple-darwin9.0.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/i686-apple-darwin9/4.0.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld) is GNU ld... no
checking whether the linker (/usr/libexec/gcc/i686-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/i686-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
jconfig.h is unchanged
Sebs-Mac-Mini:jpeg-6b Seb$ sudo make
make: Nothing to be done for `all'.
Sebs-Mac-Mini:jpeg-6b Seb$ mkdir -p /usr/local/include
Sebs-Mac-Mini:jpeg-6b Seb$ mkdir -p /usr/local/bin
Sebs-Mac-Mini:jpeg-6b Seb$ mkdir -p /usr/local/lib
Sebs-Mac-Mini:jpeg-6b Seb$ mkdir -p /usr/local/man/man1
Sebs-Mac-Mini:jpeg-6b Seb$ sudo make install
/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
Sebs-Mac-Mini:jpeg-6b Seb$ cd /SourceCache/php-5.2.4/ext/gd
Sebs-Mac-Mini:gd Seb$ sudo phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Sebs-Mac-Mini:gd Seb$ sudo ./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
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-apple-darwin9.0.0
checking host system type... i686-apple-darwin9.0.0
checking target system type... i686-apple-darwin9.0.0
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for GD support... yes, shared
checking for the location of libjpeg... /usr/local/lib
checking for the location of libpng... /usr/X11R6
checking for the location of libz... /usr
checking for the location of libXpm... /usr/X11R6
checking for FreeType 1.x support... no
checking for FreeType 2... /usr/X11R6
checking for T1lib support... no
checking whether to enable truetype string function in GD... no
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
checking for jpeg readheader in -ljpeg... yes
checking for png writeimage in -lpng... yes
checking for XpmFreeXpmImage in -lXpm... yes
checking for FT NewFace in -lfreetype... yes
checking for ld used by gcc... /usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld) is GNU ld... no
checking for /usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -p
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm -p output from gcc object... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
checking if gcc static flag works... rm: conftest.dSYM: is a directory
yes
checking if gcc supports -fno-rtti -fno-exceptions... rm: conftest.dSYM: is a directory
no
checking for gcc option to produce PIC... -fno-common
checking if gcc PIC flag -fno-common works... rm: conftest.dSYM: is a directory
yes
checking if gcc supports -c -o file.o... rm: conftest.dSYM: is a directory
yes
checking whether the gcc linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin9.0.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
Sebs-Mac-Mini:gd Seb$ sudo make
/bin/sh /SourceCache/php-5.2.4/ext/gd/libtool --mode=install cp ./gd.la /SourceCache/php-5.2.4/ext/gd/modules
cp ./.libs/gd.so /SourceCache/php-5.2.4/ext/gd/modules/gd.so
cp ./.libs/gd.lai /SourceCache/php-5.2.4/ext/gd/modules/gd.la
----------------------------------------------------------------------
Libraries have been installed in:
/SourceCache/php-5.2.4/ext/gd/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD LIBRARYPATH' environment variable
during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Sebs-Mac-Mini:gd Seb$ sudo make install
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20060613/
Installing header files: /usr/include/php/
Sebs-Mac-Mini:gd Seb$</pre>

Nov 11, 2007 12:16 PM in response to sebf

Since you mention installing MySQL, I assume you are not using Leopard Server. The instructions you followed are meant (as mentioned in the tutorial) for Leopard Server.

That said, they also work on a CLEAN Leopard Client install (which yours probably isn't anymore).

From the output you show, the extension compiled and installed correctly. Make sure you have added the extension to /etc/php.ini
Other than that, try and find out what changes you made that could have an impact.

Nov 11, 2007 1:01 PM in response to pterobyte

Good point, I am using the standard versions of Leopard (and not the server edition), not too sure if this would make too much difference.

I have added: <pre>extension=gd.so</pre> to my /etc/php.ini and restarted with no success.

I am getting an odd error in my error_log file though, perhaps its a file permissions thing or it can't find gd.so, if so where abouts should it be located and what permissions should it have?

error_log
<pre>[Sun Nov 11 20:59:05 2007] [notice] caught SIGTERM, shutting down
[Sun Nov 11 20:59:07 2007] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
mod_bonjour: Skipping user 'Seb' - cannot read index file '/Users/Seb/Sites/index.html'.
PHP Warning: PHP Startup: Unable to load dynamic library './gd.so' - (null) in Unknown on line 0
[Sun Nov 11 20:59:08 2007] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 11 20:59:08 2007] [notice] Digest: done
[Sun Nov 11 20:59:08 2007] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured -- resuming normal operations</pre>

Nov 11, 2007 4:29 PM in response to sebf

I followed the instructions from topicdesk exactly. The gd.so library builds as advertises but does not test properly when a 'make test' is executed. After correctly modifying my php.ini, the web log is telling me that gd.so fails to load - so there is something wrong somewhere. I am running the php 5.2.4 and apache 2.2. (Note: I ran a 'make test' after copying the library to the correct location just to see if it was working.)

Nov 11, 2007 5:20 PM in response to Adam Wizon

Here are a snippet of the errors from 'make test'
----------
Build complete.
Don't forget to run 'make test'.

PHP Warning: PHP Startup: Unable to load dynamic library './gd.so' - (null) in Unknown on line 0
dyld: NSLinkModule() error
dyld: Symbol not found: php_siggif
Referenced from: /Users/awizon/SourceCache/php-5.2.4/ext/gd/modules/gd.so
Expected in: flat namespace

PHP Warning: PHP Startup: Unable to load dynamic library './gd.so' - (null) in Unknown on line 0
dyld: NSLinkModule() error
dyld: Symbol not found: php_siggif
Referenced from: /Users/awizon/SourceCache/php-5.2.4/ext/gd/modules/gd.so
Expected in: flat namespace


=====================================================================
CWD : /Users/awizon/SourceCache/php-5.2.4/ext/gd
PHP : /usr/bin/php
Extra dirs :
=====================================================================
Running selected tests.
FAIL imagecreatefrompng() and empty/missing file [tests/001.phpt]
FAIL Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd)) [tests/bug19366.phpt]
^Cmake: * [test] Interruptpt]


----------------
The 'unable to load dynamic library' is also happening in the webserver.

Nov 11, 2007 10:34 PM in response to Adam Wizon

I have the same issue as Adam Wizon. I followed pterobyte comprehensive tutorials and everything installed successfully on a Leopard Server, however when I attempt to load the GD extension, I receive the same error when performing a 'make test'. I completed the 'make install' process and now upon any CLI issued "php -m" or "php -i" command, I get the following:

dyld: NSLinkModule() error
dyld: Symbol not found: php_siggif
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/gd.so
Expected in: flat namespace

Trace/BPT trap


When I comment out the gd.so extension in /etc/php.ini then this behavior disappears, so it is definitely related to the GD module and this configuration of PHP. With the extension enabled, I am able to generate graphics in PHP and utilize the GD module to a limited degree, however I am unable to access the Freetype module and using ImageTTFText commands produces a 0 byte display result. Any insight and potential fix suggestions would be greatly appreciated.

Best,

Hal.

Nov 12, 2007 12:32 AM in response to MrHali

@sebf
Check php.ini for
extension_dir = "./"
and comment it out or remove it if present.




@Adam Wizon and MrHali
The CLI version of PHP compiled into OS X Server is not capable of loading dynamic libraries. Thus make test and php -m will fail.


@All using Leopard Client
I just did a clean install of Leopard Client, enabled PHP5 in /etc/apache2/httpd.conf, applied the tutorial. Works without issues and info.php shows the GD Library.
As I mentioned before, no particular testing has been done on client and I will not further investigate this. Sorry, can't test all variations. Even just installing MySQL (which is already present on Server) can change the picture.


@MrHali
It is possible that not all functions are available through the module. Obviously we don't have as much control over what is installed when using the pre-made modules.
For full functionality it would be much better to compile everything needed into PHP5. I am working on this. Not as easy under Leopard as under Tiger, since a few libraries which are compiled into PHP are missing in the sources.

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.

How to install GD2 Library ?

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