SlackwarePHPGDError

How to solve a PHP gd error

This is a problem I encountered under Slackware 14.1. Please let me know if this is also a problem under other versions of Slackware.

Sometimes, on a CLI-only Slackware install, you will get the following PHP error:

# php --version
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/gd.so'
- libX11.so.6: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.4.29 (cli) (built: Jun  9 2014 15:07:42)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Yes, I know, PHP is a piece of ____________, but here is the problem: I need to install a web application that requires PHP (sheeesh). How to solve this really quickly?

Well, actually, the error message is misleading: the problem is not that gd is not installed, it is that it's missing some of its own dependencies. You can test that with the following command:

# ldd /usr/lib/php/extensions/gd.so
        linux-gate.so.1 (0xffffe000)
        libt1.so.5 => /usr/lib/libt1.so.5 (0xb761b000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb74e4000)
        libXpm.so.4 => not found                                       <--- Missing!
        libpng14.so.14 => /usr/lib/libpng14.so.14 (0xb74b9000)
        libz.so.1 => /lib/libz.so.1 (0xb74a2000)
        libjpeg.so.8 => /usr/lib/libjpeg.so.8 (0xb746a000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb73dd000)
        libbz2.so.1 => /lib/libbz2.so.1 (0xb73cc000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb73b2000)
        libc.so.6 => /lib/libc.so.6 (0xb7227000)
        libm.so.6 => /lib/libm.so.6 (0xb71e4000)
        libxcb.so.1 => not found                                       <--- Missing!
        libXau.so.6 => not found                                       <--- Missing!
        libXdmcp.so.6 => not found                                     <--- Missing!
        libdl.so.2 => /lib/libdl.so.2 (0xb71df000)
        /lib/ld-linux.so.2 (0xb76e7000)

The answer to this one is therefore really simple: install all these dependencies. Go to your favourite Slackware mirror, into the directory /pub/Slackware-14.1/slackware/x/ and download the following files (HINT: mget libX* libx* is your friend!):

-rw-r--r-- 1 root root 2687544 Sep 20  2013 libX11-1.6.2-i486-1.txz
-rw-r--r-- 1 root root     198 Sep 20  2013 libX11-1.6.2-i486-1.txz.asc
-rw-r--r-- 1 root root     469 Jun 22  2013 libXau-1.0.8-i486-1.txt
-rw-r--r-- 1 root root   25912 Jun 22  2013 libXau-1.0.8-i486-1.txz
-rw-r--r-- 1 root root     198 Jun 22  2013 libXau-1.0.8-i486-1.txz.asc
-rw-r--r-- 1 root root     341 May  4  2012 libXdmcp-1.1.1-i486-1.txt
-rw-r--r-- 1 root root   47820 May  4  2012 libXdmcp-1.1.1-i486-1.txz
-rw-r--r-- 1 root root     198 May  4  2012 libXdmcp-1.1.1-i486-1.txz.asc
-rw-r--r-- 1 root root     313 Sep 20  2013 libXpm-3.5.11-i486-1.txt
-rw-r--r-- 1 root root   74952 Sep 20  2013 libXpm-3.5.11-i486-1.txz
-rw-r--r-- 1 root root     198 Sep 20  2013 libXpm-3.5.11-i486-1.txz.asc
-rw-r--r-- 1 root root     446 Sep  7  2013 libxcb-1.9.1-i486-1.txt
-rw-r--r-- 1 root root  809760 Sep  7  2013 libxcb-1.9.1-i486-1.txz
-rw-r--r-- 1 root root     198 Sep  7  2013 libxcb-1.9.1-i486-1.txz.asc

When you are done, just launch the command installpkg ./*.txz in the directory where these files are saved, and you should be in business!

You can check the correction with:

# ldd /usr/lib/php/extensions/gd.so | grep -i -c not.found
0

Zero missing libraries, that is a very good start. What does php --version says?

# php --version           
PHP 5.4.29 (cli) (built: Jun  9 2014 15:07:42) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

No more error messages! Hope this helps!!