note 31606 added to zend.creating
| From: | Ed at rack1 dot php dot net | Date: | Mon, 28 Apr 2003 03:55:10 +0000 |
| Subject: | note 31606 added to zend.creating | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47187@lists.php.net to get a copy of this message | ||
Thank you very much for the comments above!
Here is a distillation of how to compile your module as a dynamic library, placing it in your web
server and loading it in your test .php file being served (PHP 4.3.1).
*** Compiling a module as a .so
$ cd ext/mystuff
$ cc -fpic -DCOMPILE_DL_MYSTUFF=1 -I/usr/local/include -I../../TSRM -I../.. -I../../main
-I../../Zend -I../../ext/bcmath/libbcmath/src -c -o mystuff.o mystuff.c
$ cc -shared -L/usr/local/lib -rdynamic -o mystuff.so mystuff.o
*** Move it to the web server (doc root is /www)
$ cp mystuff.so /www/.
$ chmod 644 /www/mystuff.so
*** load the module in the .php file for testing purposes
<?
dl('/mystuff.so');
/* your php code here */
?>
The other thing that threw me off my tracks is that when dealing with strings you can allocate
memory with emalloc and return the result with the RETURN_STRING macro (duplicate set to 0) and
presumably PHP will take care of the efree -- or else I got it wrong and have plenty of leaks ;-)
--
http://www.php.net/manual/en/zend.creating.php
http://master.php.net/manage/user-notes.php?action=edit+31606
http://master.php.net/manage/user-notes.php?action=delete+31606
http://master.php.net/manage/user-notes.php?action=reject+31606