Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)

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..
like image 932
sunset Avatar asked Sep 02 '11 13:09

sunset


1 Answers

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
like image 171
ArtemGr Avatar answered Sep 17 '22 21:09

ArtemGr