I was given a libxxx.so
file which i can't view it's source code and i can compile my c file with the next command:
gcc -ldl libxxx.so my.c -a a.out
a.out
worked well in command line. But after i wrapped it into a PHP
extension, PHP
showed a message like this:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/myextension.so' - /usr/lib64/php/modules/myextension.so: undefined symbol: xxxfunction in Unknown on line 0
xxxfunction is a function exported by libxxx.so
.
I'm new to C
and I think the problem is the way of compiling my PHP
extension, i searched google but didn't find the answer.
I'm wondering whether there is an option like -ldl in gcc so i can specify that i'm going to use the libxxx.so in my PHP
extention.
I compiled my extension by next steps:
cd myextension/
phpize
./configure
make
make install
I have moved libxxx.so
file to /usr/local/lib
.
My /etc/ld.so.conf:
include ld.so.conf.d/*.conf
/usr/local/lib
I have runed lddconfig
.