Help compiling Dynamically Linked Module
| From: | Jeff Lang | Date: | Fri, 03 May 2002 14:33:59 +0000 |
| Subject: | Help compiling Dynamically Linked Module | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-95903@lists.php.net to get a copy of this message | ||
I am trying to compile and run the tutorial, from the php documentation, on extending php.
I am currently working in SunOS v5.7 with gcc version 2.95 19990728. I am running PHP 4.2.0 statically in Apache 1.3.24
I have copied the first_module.c file and I can compile it with the following command
~~~/php-4.2.0/ext> gcc -fpic -DCOMPILE_DL=1 -I/usr/local/include -I../main -I../TSRM -I. -I.. -I../Zend -c -o first_module/first_module.o first_module/first_module.c
I can also link with the following command
~~~/php-4.2.0/ext>gcc -shared -L/usr/local/lib -dynamic -o first_module/first_module.so first_module/first_module.o
I then copy this module to the working directory of my php script and call it like this:
<?
dl("first_module.so");
$param = 2;
$return = first_module($param);
print("We sent '$param' and got '$return'");
?>
the file has execute and read permissions set for all users.
the file is located by php, but I get this error:
Warning: Invalid library (maybe not a PHP library) 'first_module.so' in /export/home/jlang/htdocs/phpscript/modtest.php on line 5
can anyone help me find out why this file is not correctly loading
Thanks,
Jeff Lang