繁体   English   中英

尝试使用PNG和JPEG支持构建PHP和GD

[英]Trying to build PHP and GD with PNG and JPEG support

浏览器显示错误消息

致命错误:在...中调用未定义的函数imagecreatefrompng()

以下是失败的源代码:

$img = imagecreatefrompng($file);

这是一个原生的PHP函数。

我打算建立GD和PHP。

GD libgd-2.2.4库构建得很好:

Support for Zlib:                 yes
Support for PNG library:          yes
Support for JPEG library:         yes
Support for WebP library:         no
Support for TIFF library:         no
Support for Freetype 2.x library: yes
Support for Fontconfig library:   no
Support for Xpm library:          yes
Support for liq library:          no
Support for pthreads:             yes

我使用了命令:

./configure \
  --prefix=/home/stephane/programs/install \
  --with-jpeg=/home/stephane/programs/install \
  --with-png=/home/stephane/programs/install \
  --with-freetype=/home/stephane/programs/install \
  --with-zlib=/home/stephane/programs/install \
  --with-xpm

make
make install

makemake install命令成功完成。

PHP php-5.6.30引擎也很好:

checking for GD support... yes
checking for the location of libvpx... no
checking for the location of libjpeg... /home/stephane/programs/install
checking for the location of libpng... /home/stephane/programs/install
checking for the location of libXpm... no
checking for FreeType 2... /home/stephane/programs/install
checking for T1lib support... no
checking whether to enable truetype string function in GD... yes

checking for gdSetErrorMethod in -lgd... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromWebp in -lgd... no
checking for gdImageCreateFromJpeg in -lgd... yes
checking for gdImageCreateFromXpm in -lgd... yes
checking for gdImageStringFT in -lgd... yes
checking for gdVersionString in -lgd... yes
checking for gdImageCreate in -lgd... yes

我使用了命令:

./configure \
  --prefix=/home/stephane/programs/install \
  --with-apxs2=/home/stephane/programs/install/apache/bin/apxs \
  --with-config-file-path=/home/stephane/programs/php-5.6.30/ \
  --with-mysql=/home/stephane/programs/install/mariadb \
  --with-mysqli=/home/stephane/programs/install/mariadb/bin/mysql_config \
  --with-pdo-mysql=/home/stephane/programs/install/mariadb \
  --with-zlib-dir=/home/stephane/programs/install \
  --with-jpeg-dir=/home/stephane/programs/install \
  --with-png-dir=/home/stephane/programs/install \
  --with-gd=/home/stephane/programs/install \
  --enable-gd-native-ttf \
  --with-freetype-dir=/home/stephane/programs/install \
  --enable-ftp \
  --enable-xml \
  --enable-zip \
  --with-bz2 \
  --enable-wddx \
  --enable-libgcc \
  --without-pear \
  --enable-mbstring \
  --enable-intl \
  --enable-calendar \
  --with-openssl \
  --with-curl \
  --enable-debug \
  --disable-phar \
  --enable-fpm \
  --with-oci8=instantclient,/home/stephane/programs/oracle/instantclient_11_2

make
make install

makemake install命令也很成功。

以下是创建的库文件:

$ ll /home/stephane/programs/install/lib/
total 22M
-rw-r--r-- 1 stephane 6,3M juin  12 14:30 libfreetype.a
-rwxr-xr-x 1 stephane 1,1K juin  12 14:30 libfreetype.la*
lrwxrwxrwx 1 stephane   21 juin  12 14:30 libfreetype.so -> libfreetype.so.6.13.0*
lrwxrwxrwx 1 stephane   21 juin  12 14:30 libfreetype.so.6 -> libfreetype.so.6.14.0*
-rwxr-xr-x 1 stephane 3,0M juin  12 14:30 libfreetype.so.6.13.0*
-rwxr-xr-x 1 stephane 3,1M juin  10 13:11 libfreetype.so.6.14.0*
-rw-r--r-- 1 stephane 1,7M juin  12 15:08 libgd.a
-rwxr-xr-x 1 stephane 1,2K juin  12 15:08 libgd.la*
lrwxrwxrwx 1 stephane   14 juin  12 15:08 libgd.so -> libgd.so.3.0.4*
lrwxrwxrwx 1 stephane   14 juin  12 15:08 libgd.so.3 -> libgd.so.3.0.4*
-rwxr-xr-x 1 stephane 1,1M juin  12 15:08 libgd.so.3.0.4*
-rw-r--r-- 1 stephane 2,2M juin   7 12:36 libjpeg.a
-rwxr-xr-x 1 stephane  938 juin   7 12:36 libjpeg.la*
lrwxrwxrwx 1 stephane   16 juin   7 12:36 libjpeg.so -> libjpeg.so.9.2.0*
lrwxrwxrwx 1 stephane   16 juin   7 12:36 libjpeg.so.9 -> libjpeg.so.9.2.0*
-rwxr-xr-x 1 stephane 1,2M juin   7 12:36 libjpeg.so.9.2.0*
-rw-r--r-- 1 stephane 1,7M juin  10 12:43 libpng16.a
-rwxr-xr-x 1 stephane  958 juin  10 12:43 libpng16.la*
lrwxrwxrwx 1 stephane   19 juin  10 12:43 libpng16.so -> libpng16.so.16.29.0*
lrwxrwxrwx 1 stephane   19 juin  10 12:43 libpng16.so.16 -> libpng16.so.16.29.0*
-rwxr-xr-x 1 stephane 905K juin  10 12:43 libpng16.so.16.29.0*
lrwxrwxrwx 1 stephane   10 juin  10 12:43 libpng.a -> libpng16.a
lrwxrwxrwx 1 stephane   11 juin  10 12:43 libpng.la -> libpng16.la*
lrwxrwxrwx 1 stephane   11 juin  10 12:43 libpng.so -> libpng16.so*
-rw-r--r-- 1 stephane 151K juin   5 22:46 libz.a
lrwxrwxrwx 1 stephane   14 juin   5 22:46 libz.so -> libz.so.1.2.11*
lrwxrwxrwx 1 stephane   14 juin   5 22:46 libz.so.1 -> libz.so.1.2.11*
-rwxr-xr-x 1 stephane 120K juin   5 22:46 libz.so.1.2.11*
drwxrwxr-x 4 stephane 4,0K juin   8 17:08 php/
drwxrwxr-x 2 stephane 4,0K juin  12 15:08 pkgconfig/

但是看看phpinfo显示一个不完整的GD部分:

GD Support  enabled
GD headers Version  2.2.4
GD library Version  2.2.4
GIF Read Support    enabled
GIF Create Support  enabled
WBMP Support    enabled
XPM Support enabled
libXpm Version  30411
XBM Support enabled

没有安装默认包:

$ sudo apt-cache show libpng
N: Impossible de trouver le paquet libpng
E: Aucun paquet n'a été trouvé
[stephane@stephane-ThinkPad-X201 fatec]
$ sudo apt-cache show libjpeg
N: Impossible de trouver le paquet libjpeg
E: Aucun paquet n'a été trouvé

这里有一些关于我的操作系统和机器:

$ uname -a
Linux stephane-ThinkPad-X201 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

我的Apache配置确实指向正确的PHP目录:

<IfModule mod_php5.c>
    PHPIniDir "/home/stephane/programs/php-5.6.30"
</IfModule>

$ ll /home/stephane/programs/php-5.6.30/php.ini
-rw-r--r-- 1 stephane 73K juin  12 14:05 /home/stephane/programs/php-5.6.30/php.ini

我刚刚解决了这个问题。

我只是做了make clean做之前命令make命令。

现在我根据需要启用了GD:

GD Support  enabled
GD headers Version  2.2.4
GD library Version  2.2.4
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.8.0
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version unknown
PNG Support enabled
libPNG Version  1.6.29
WBMP Support    enabled
XPM Support enabled
libXpm Version  30411
XBM Support enabled

我总是错误地认为./configure命令会使编译对象无效。 不是这样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM