Building PHP C extensions on Ubuntu 9.10

I have just taken over maintenance of the PECL Direct IO extension as it has been unmaintained for a while. Naturally the first thing I did before writing any new code was to check out the extension from SVN and try and build it. Building the source was fine but when I tried make test it failed producing output like the following:

PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/gd.so' - 
modules/gd.so: cannot open shared object file: No such file or 
directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - 
modules/gd.so: cannot open shared object file: No such file or 
directory in Unknown on line 0

The default PHP package on Ubuntu 9.10 is fairly minimalist. Most extensions are provided as separate packages which include an INI file and a dynamic library. The dynamic library is stored in:

/usr/lib/php5/20060613+lfs

And the INI file for each extension is in:

/etc/php5/conf.d.

The make tests rule in the generated Makefile in the extension you are compiling modifies the path that PHP searches for extensions by to point to the modules directory within the extension source. So PHP, which is used to run the tests, cannot find the extensions.

I’ve found the easiest way (if slightly hacky) to fix the make test failure is just to copy the .so files from the PHP5 extension directory in to the modules directory within the extension source.

Tags: ,

2 Responses to “Building PHP C extensions on Ubuntu 9.10”

  1. optik Says:

    Yes, I had same problem when I develop my extension (http://hg.mirin.cz/phpincpath/file/tip). But copiing isn’t very good. Do you know another solution
    how to push under “make test” another php.ini? Maybe compiling separate instance of php for extension development, but it isn’t also very handy.

  2. Autonomic Pilot Blogs » Blog Archive » unit tests for PECL extensions and how to make them work Says:

    […] sqlite3-0.6 directory for the modules The lovely Cyberspice has made an entry about this already building php c extensions on ubuntu 9.10 unfortunately I didn’t see this until after I went my own, different route. Thanks to Derick […]

Leave a Reply