Page 1 of 2

PHP and GD

Posted: Fri Jun 11, 2004 8:01 am
by maxmegalon
Hi, I'm trying to install GD so that I can use some of the graph classes I found on

http://www.phpclasses.org/search.html?w ... o_search=1

It seemed after some experimentation that I was in need of installing GD before things would work.
What I found was that php's configure needed some variables set to succesfully build GD (Note: I'm using php in conjunction with mysql and apache, so therefore there are some variables set for these as well)

./configure --with-apache=../apache_1.3.31 --with-mysql=/usr/local/mysql --with-gd --with-zlib-dir=/usr/local/lib --with-jpg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --enable-gd-native-ttf

I then installed php using:
make
make install

Apache was installed using
./configure --with-layout=Apache --activate-module=src/modules/php4/libphp4.a
make
make install

After restarting apache I still get error messages that seem to point to GD not being installed correctly:

Call to undefined function: imagettfbbox() in /usr/local/apache/htdocs/stats/z/graph.php on line 1269

Can anyone tell me what is wrong? Do I also have to configure apache for the use of GD?
Is there a way of getting more info about the error message or a more detailed error message?

Posted: Fri Jun 11, 2004 8:22 am
by redmonkey
Did you rebuild Apache after rebuilding PHP?

You will also need to do a 'make clean' for both prior to rebuilding.

Posted: Fri Jun 11, 2004 8:28 am
by redmonkey
Should probably add that phpinfo() will show quickly if GD is installed or not.

Posted: Fri Jun 11, 2004 8:43 am
by maxmegalon
I rebuild apache after installing php

php_info shows:

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

Posted: Fri Jun 11, 2004 9:01 am
by redmonkey
Well there doesn't appear to be anything obvious, there are only a few small differences for my surrent setup....

Code: Select all

GD Support:			enabled
GD Version:			bundled (2.0.22 compatible)
FreeType Support:	enabled
FreeType Linkage:	with freetype
GIF Read Support:	enabled
JPG Support:		enabled
PNG Support:		enabled
WBMP Support:		enabled
XBM Support:		enabled
The only difference I can see is the version compatability (i.e. 22 vs 23 on the incremental) and I compiled with freetype. Which version of PHP are you using? I'm currently running 4.3.6 and the 'imagettfbbox()' function is definately recognised.

It's probably not much use but here is my base configure.....

Code: Select all

#! /bin/sh
#

'./configure' \
'--prefix=/usr/local/php' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
'--with-curl=/usr/src/curl-7.11.2' \
'--with-gd' \
'--with-jpeg-dir=/usr/lib' \
'--with-png-dir=/usr/lib' \
'--with-freetype-dir=usr/lib' \
'--with-zlib-dir=/usr/lib' \
'--with-bz2=/usr/lib' \
'--enable-bcmath' \
'--enable-calendar' \
'--enable-ftp' \
"$@"

Posted: Fri Jun 11, 2004 9:42 am
by maxmegalon
I'm running php 4.3.7

Is there a possibiliuty to get a more detailed error message in some way that could maybe hint to a solution (just a thought) that you know of? E.g. can I run the script on a command line and maybe see a bit more about what is going wrong?

Posted: Fri Jun 11, 2004 9:45 am
by maxmegalon
My php config looks like this:

# php -m
[PHP Modules]
ctype
gd
mysql
overload
pcre
posix
session
standard
tokenizer
xml
zlib

[Zend Modules]

Posted: Fri Jun 11, 2004 9:54 am
by redmonkey
You would require a debug build of descriptions to get anymore info regarding the problem.

The 'call to undefined function' error is basically just that, you are trying to use an undefined function. Have you tired running some of the other GD functions? or is this specific to 'imagettfbbox'?

I have not yet built 4.3.7 so don't know if this is a bug, it wouldn't be the first time they have unintentionally left something out.

You could try building 4.3.6

Posted: Fri Jun 11, 2004 10:15 am
by maxmegalon
I had just upgraded from php 4.3.4 and reinstalled that. But the problem remained.

Just one thought. I tried to install GD via rpm before I got the sources and did the configure make make install part. Could it be that there lies a problem in that?

Posted: Fri Jun 11, 2004 10:22 am
by redmonkey
maxmegalon wrote: Just one thought. I tried to install GD via rpm before I got the sources and did the configure make make install part. Could it be that there lies a problem in that?
Quite possibly, although PHP should build with the bundled GD if you do not specify a directory. That being said though, it wouldn't hurt to remove the GD version installed via rpm.

Posted: Fri Jun 11, 2004 10:34 am
by maxmegalon
[quote]Quite possibly, although PHP should build with the bundled GD if you do not specify a directory. That being said though, it wouldn't hurt to remove the GD version installed via rpm[/quote]

Done that, no effect on the aforementioned problem.

Posted: Fri Jun 11, 2004 11:15 am
by redmonkey
I'm at a bit of a lose as to what to try next. The only thing I can think of now is to try installing a pre-built binary with GD enabled and see how that goes.

Have you had a look through the output of make? It should obviously fall over if it hits a major problem but there maybe something in the output of make which may give you a clue.

Have you tried any other GD specific functions?

Posted: Fri Jun 11, 2004 11:25 am
by maxmegalon
I added support for freetype since that was one major difference between your config and mine.

GD Support enabled
GD Version bundled (2.0.23 compatible)
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

If I run one of the scripts now, I get font errors like:

Warning: imagettfbbox(): Could not find/open font in /usr/local/apache/htdocs/stats/z/graph.php on line 1269

Also it seems that a PNG object is made be it unsuccesfull:

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/htdocs/stats/z/graph.php:1269) in /usr/local/apache/htdocs/stats/z/graph.php on line 1404
‰PNG
followed by a lot of nonprintable characters.

Does this ring any bells?

Posted: Fri Jun 11, 2004 11:29 am
by feyd
graph.php(1269) echo'd something before whatever header you are trying to output on graph.php(1404)..

presumably, that's the warning you are getting.. so fix that, and the header error will go away I imagine.

Posted: Fri Jun 11, 2004 11:34 am
by maxmegalon
[quote]graph.php(1269) echo'd something [/quote]

Could that be the warnings?