Click to See Complete Forum and Search --> : Creating PHP extensions for Linux


Stefan B.
06-21-2004, 07:25 AM
I have created a PHP extension. On a Windows server it compiles and runs like a charm. On a Linux system (Red Hat 9 out of the box, with PHP 4.2.2) the extension compiles but does not load.

To make things easier I have compiled the sample PHP extension (http://www.php.net/manual/de/zend.creating.php). Still no success.

/var/log/httpd/error_log says:
PHP Warning: Invalid library (maybe not a PHP library) 'first_module.so' in Unknown on line 0

This is what I have done:

1. Create "first_module.c" (the content is listed on the PHP web site, see the link above).

2. Compiled and linked:

cc -fpic -DCOMPILE_DL=1 -I/usr/local/include -I/home/sb/pro/php-4.3.5 -I/home/sb/pro/php-4.3.5/main -I/home/sb/pro/php-4.3.5/Zend -I/home/sb/pro/php-4.3.5/TSRM -c -o first_module.o first_module.c

cc -shared -L/usr/local/lib -rdynamic -o first_module.so first_module.o

3. Copied first_module.so to /usr/lib/php4

4. Created /etc/php.d/first_module.ini containing the line "extension=first_module.so".

Having done this, the error message shown above occurs when restarting httpd. Any idea what I can do to fix the problem?

Stefan