8

In the past i did create a shared library that now I would like to use it inside a php extension. Is it possible to do that? As I've seen in the config.m4 file PHP_NEW_EXTENSION() asks for the .cc . The problem is that i don't want to expose my code. I just want to use the header and the shared library i've creaded in c under ubuntu.For the php extention i did create a : config.m4, php_c.h and php_c.cc.

Please help!. THX APPRECIATE I did put in the config file this:

libs=mylib.so; 
PHP_ADD_LIBRARY_WITH_PATH(libs, $EXTERNAL_LIB_DIR, ?? what to add here);

I obtain the following:

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) '/home/foder/mylib.so'in Unknown on line 0

php: symbol lookup error:

/usr/php5/20090626+lfs/vehicles.so: undefined symbol: _ZN3CarC1Ei (where vehicles.so) is a php so created with: phpize, ./configure --enable-vehicle make..
1
  • 1
    You can't just take some random .so and turn it into a PHP extension with a couple lines of config. There's a fair amount of work involved: devzone.zend.com/article/1021 Commented Sep 2, 2011 at 14:34

1 Answer 1

16
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) '/home/foder/mylib.so'in Unknown on line 0

This message means there's no "get_module" function in the ".so".
Make sure the PHP extension source contains the lines:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

and

#ifdef COMPILE_DL_MYLIB
ZEND_GET_MODULE(mylib)
#endif
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.