-   Slackware (
-   -   php5 compile woes: undefined function imagettftext (

BCarey 01-22-2006 10:08 PM

php5 compile woes: undefined function imagettftext
well, that's pretty much the problem, I get: [CODE]Fatal error: Call to undefined function imagettftext()[\CODE] when I run, eg. the following

 DEFINE ("TTF_DIR","/usr/X11R6/lib/X11/fonts/TTF/" );

$im = imagecreatetruecolor (400, 100);
$black = imagecolorallocate ($im, 0, 0, 0);
$white = imagecolorallocate ($im, 255, 255, 255);

imagerectangle ($im,0, 0,399,99 ,$black);
imagefilledrectangle ($im,0, 0,399,99 ,$white);

imagettftext ($im, 30, 0, 10, 40 , $black, TTF_DIR. "arial.ttf", "Hello World!");

header ("Content-type: image/png" );
imagepng ($im);       

This is my config line:

./configure --with-apxs --with-mysql=/usr/share/mysql --with-unixODBC --with-pgsql
--with-mysqli=/usr/bin/mysql_config --with-xmlrpc --with-gd --enable-gd-native-ttf
--with-jpeg-dir=/usr --with-png -with-ttf-dir=/usr/lib --with-zlib-dir=/usr/include/zlib

Any help would be greatly appreciated.


irpstrcr 01-22-2006 10:22 PM

A quick guess would be php looking for libfreetype in the wrong place.

BCarey 01-22-2006 10:35 PM


Originally Posted by irpstrcr
A quick guess would be php looking for libfreetype in the wrong place.

It would seem that way, but I did specify the path to libfreetype in the configuration.


irpstrcr 01-22-2006 10:46 PM

ask the mighty ldd if it is where it thinks it is

ldd /path/to/php <-- this will tell you if, what and where the libs php knows about reside

or if you just want to see if it knows about

ldd /path/to/php | grep libfreetype

BCarey 01-22-2006 10:54 PM

Indeed I get
Code: => /usr/local/lib/ (0xb7e17000)
which seems to be okay.

Thanks for teaching me the ldd command. :=)


abbnam 05-19-2007 12:42 AM

after all that......
I also had this very same problem. Even though i compiled/linked against the freetype library (many-many times!) and verified it using ldd (as described above) I still received the error.

The problem, it turns out, is that I had two php executables, one in "/usr/bin" and one in "/usr/local/bin"

after "make install" the output was being installed in "/usr/bin" but my path was picking up the "/usr/local/bin" which had an older (non-freetype linked) php executable.

If, like me, you have tried everything suggested on the internet (including the previous posts here), then check you don't have two copies of php...


All times are GMT -5. The time now is 10:48 PM.