Trying to build PHP and GD with PNG and JPEG support

The browser displays an error message

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

Here is the source code that doesn't work:

$img = imagecreatefrompng($file);

      

This is a native PHP function.

I intend to create both GD and PHP.

The GD library libgd-2.2.4

was built just fine:

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

      

I used the commands:

./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

      

The teams make

and make install

were successful.

The PHP engine php-5.6.30

was also built perfectly:

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

      

I used the commands:

./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

      

The teams make

and make install

were also successful.

Here are the library files that were created:

$ 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/

      

But look at phpinfo

shows the incomplete GD section:

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

      

Installed packages are not installed by default:

$ 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é

      

Here's a little about my OS and machine:

$ 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

      

My Apache config points to the correct PHP directory:

<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

      

+3


source to share


1 answer


I just solved the problem.

I just needed to execute the command make clean

before executing the command make

.

Now I have GD enabled as needed:



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

      

I have always and erroneously assumed that the command ./configure

would invalidate the compiled objects. Not this way.

0


source







All Articles