首页 > C风格编程语言 > PHP编程技术 > PHP Fatal error: Call to undefined function imaget
2010
10-27

PHP Fatal error: Call to undefined function imaget

在测试机上装了 yiiframework 玩了玩,没想到验证码显示不出来。
PHP 错误日志:



PHP Fatal error: Call to undefined function imagettfbbox() in …


php -m 发现 GD 已经编译进去了,而 freetype 在编译配置时也加了 –with-freetype-dir 。
不得其解,重新运行下编译配置看看:



./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-zlib


配置输出:



checking for GD support… yes
checking for the location of libjpeg… yes
checking for the location of libpng… yes
checking for the location of libXpm… no
checking for FreeType 2… yes
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… (cached) yes
checking for floorf… (cached) yes


注意其中有一行“whether to enable truetype string function in GD… no”,应该就是这个问题了吧。
加上 –enable-gd-native-ttf,重新编译并重启 PHP-FPM,问题依旧……


最后把 GD 相关的选项全选上了:



./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-xpm-dir –with-freetype-dir –with-t1lib –enable-gd-native-ttf –with-zlib


问题依旧!


……没折,该不会编译过程又抽风了吧。
清空,并重新编译:



make clean
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –enable-fpm –enable-sockets –enable-pdo –with-pdo-mysql=/usr –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-zlib
make && make install


问题解决了,感谢党和人民的支持!


更多PHP安装过程请参考:《Gentoo 下搭建 Nginx+ MySQL + PHP (fastcgi) 环境》


作者:Hily 原始链接:http://hily.me/blog/2010/03/php-undefined-imagettfbbox/


留下一个回复