2017-06-12 1 views
3

PNGとJPEGのサポートをPHPとGDを構築しようとすると、ブラウザは、ここでエラーメッセージ

Fatal error: Call to undefined function imagecreatefrompng() in...

を表示する失敗したソースコードである:

$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é 
[[email protected] fatec] 
$ sudo apt-cache show libjpeg 
N: Impossible de trouver le paquet libjpeg 
E: Aucun paquet n'a été trouvé 

ここに私のOSとマシンに関するビットがあります:

$ 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 
+1

あなたのコードの一部を共有すること、エラーが含まれていること、または動作していないことを検討してください。 –

+0

これはPHPの本来の関数呼び出しです。これ以上のコードは必要ありません。 – Stephane

+0

このエラーもまた、関数が未定義であることを示します。 – Stephane

答えて

0

makeコマンドを実行する前に、make cleanコマンドを実行するだけでした。

今、私は私が必要な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コマンドは、コンパイルされたオブジェクトが無効になり仮定。そうではありません。