Re: Wrapping existing C code
| From: | Amit Sharma | Date: | Wed, 07 Jul 2004 13:23:51 +0000 |
| Subject: | Re: Wrapping existing C code | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-943@lists.php.net to get a copy of this message | ||
Yes! you need to modify your config.m4 such that the library you need gets linked. The easiest way to verify is using ldd. If you built php with your extension you should see the name of the library when you do "ldd /path/to/php/php" or if you built the extension as an independent shared object you should see the library linked to the .so thus "ldd /path/to/your/extension/yourextension.so" should list your library.
Hope this helps and please correct me if this is wrong I am also new to building extensions.
-Amit
Andre Naess wrote:
Hi I've been going through the available tutorials on how to develop a PHP extension, but there is still one thing I don't quite understand. I have this shared library containing some C code I need to wrap so that it can be accessed from php. I've gone through the tutorials and built an extension which calls one of the functions in the library. For simplicity I added the absolute path to the header files at the start of my extension, just to test if it would work. I've compiled and installed it, and when I call the function I get a relocation error from Apache because it can't find the library function I'm calling. Say the library is in /home/edmi/libEdmi.so, how do I make this available to Apache? Is it something I need to configure in apache, or is it something I have to do in config.m4 for my extension? I tried setting LD_LIBRARY_PATH in the same shell as I called apachectl restart from, with no luck. In the tutorials I've seen so far this problem doesn't seem to be covered, the libraries that are wrapped just magically seem to be available. Thanks for your time. André Næss