开发者

Building libphp5.so for embedding in C/C++

开发者 https://www.devze.com 2023-03-25 21:31 出处:网络
I\'ve been trying to build and link libphp5.so using the --enable-embed configure option, on OSX. This doesn\'t complete succ开发者_C百科essfully, failing primarily because of object files not being f

I've been trying to build and link libphp5.so using the --enable-embed configure option, on OSX. This doesn't complete succ开发者_C百科essfully, failing primarily because of object files not being found during the linking stage.

There are reports that the --enable-embed option has been broken on OSX for a long time.

Has anybody had any success doing this, linking and embedding the Zend Engine functions into a C/C++ app?


I finally managed to do this after lots of failed attempts. Here is a configure string that will build the libphp5.a library on OSX for PHP 5.3.6:

./configure --enable-embed=static --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-iconv

Then, when linking to C/C++ code, you need to add libresolv to prevent link errors relating to DNS functions in the Zend Engine. For example:

g++ -o yourapp src/main.o -Lpath/to/libs -lphp5 -lresolv

Hope this helps somebody one day :-)


I use some like this:

CFLAGS='-m32 -m64' LDFLAGS='-m32 -m64' CPPFLAGS="-m32 -m64" ./configure  --prefix=/usr/local --disable-cli --enable-embed --build="build folder" --with-iconv-dir=/usr/local/opt/libiconv/

And enable cli later with phpize, this work with 5.2.10 and up.

Edit: look here: http://forums.wxphp.org/viewtopic.php?f=6&t=42 it is my full resolution with makefile etc... for 5.4.17.

0

精彩评论

暂无评论...
验证码 换一张
取 消