note 31606 deleted from internals2.ze1.zendapi by cmb
| From: | cmb@php.net | Date: | Sun, 10 Jan 2021 13:25:33 +0000 |
| Subject: | note 31606 deleted from internals2.ze1.zendapi by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216117@lists.php.net to get a copy of this message | ||
Note Submitter: Ed a PHP enthusiast from NYC
----
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 ;-)