Reputation: 5040
I am trying to generate a PHP extension of a C++ program (Simstring), but I am a little stucked.
The program already propose a python and a ruby extensions working with Swig.
I followed the Swig PHP documentation but I got an error.
Here is what I have done and the result I got, maybe you can help me with that:
cd swig;
mkdir php;
ln -s ../export.cpp
ln -s ../export.h
ln -s ../export.i
swig -c++ -php -o export_wrap.cpp export.i
g++ `php-config --includes` -fPIC -c export_wrap.cpp
g++ -shared export_wrap.o -o simstring.so
sudo mv simstring.so my-php-extension-dir/
I load the extension in my php.ini but I got the following error :
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/simstring.so' - /usr/lib/php5/20121212/simstring.so: undefined symbol: _ZN6writer5closeEv in Unknown on line 0
Thanks a lot
Upvotes: 1
Views: 357
Reputation: 5040
Thanks to @zaufi, I searched more and found the answer.
I was definitively missing a file.
The right commands are the followings (please note the export_wrap.cpp
AND export.cpp
resp. export.o
AND export_wrap.o
)
g++ `php-config --includes` -fPIC -c export_wrap.cpp export.cpp
g++ -shared export.o export_wrap.o -o simstring.so
For more informations, you have to "include" the simstring.php generated file.
Upvotes: 2