I'm having a few problems using the embed sapi. I've compiled PHP with
the -enable-embed option (not with the static option) and everything
compiled ok. The contents of my sapi lib dir is as follows:
cphp # ls /usr/lib/php5/include/php/sapi/embed/
CREDITS config.m4 php5embed.dsp php_embed.h
EXPERIMENTAL config.w32 php_embed.c
My C code trying to use the sapi is as follows:
#include <php_embed.h>
int main(int argc, char *argv[])
{
PHP_EMBED_START_BLOCK(argc, argv)
zend_eval_string("echo 'Hello World!';", NULL,
"Simple Hello World App" TSRMLS_CC);
PHP_EMBED_END_BLOCK()
return 0;
}
My GCC command trying to compile it as follows:
gcc
-I/usr/lib/php5/include/php \
-I/usr/lib/php5/include/php/main \
-I/usr/lib/php5/include/php/Zend \
-I/usr/lib/php5/include/php/TSRM \
-I/usr/lib/php5/include/php/sapi \
-I/usr/lib/php5/include/php/sapi/embed \
-Wall -g
embed.c
I have tried linking this, passing -c to make a .o file then linking but
nothing helps. I always get the following errors:
/tmp/ccORuj71.o: In function `main':
/home/crisp/cphp/embed.c:5: undefined reference to `php_embed_init'
/home/crisp/cphp/embed.c:5: undefined reference to `executor_globals'
/home/crisp/cphp/embed.c:5: undefined reference to `executor_globals'
/home/crisp/cphp/embed.c:5: undefined reference to `executor_globals'
/home/crisp/cphp/embed.c:6: undefined reference to `zend_eval_string'
/home/crisp/cphp/embed.c:8: undefined reference to `executor_globals'
/home/crisp/cphp/embed.c:8: undefined reference to `executor_globals'
/home/crisp/cphp/embed.c:8: undefined reference to `php_embed_shutdown'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Now I know this SAPI is 'experimental' but many others seem to be able to
use it fine. Any help would be much appreciated. Just incase you need to
know I'm running Gentoo Linux but I compiled PHP manually aswell as emerging
it with a hack to allow the embed USE flag. Neither show any different
results. I also compiled manually using the following options:
../configure --with-curl --with-curlwrappers --enable-exif --with-gd --enable-ftp
--with-imap --with-mysql --with-mhash --with-ncurses --enable-sockets --with-readline
--enable-pcntl --with-mcrypt --enable-debug --enable-embed --with-mhash --with-mysqli
--with-openssl --with-imap-ssl
Thanks in advance, and sorry for so much copying and pasting :p
[Index of Archives]
[PHP Users]
[PHP Home]
[PHP on Windows]
[Kernel Newbies]
[PHP Classes]
[Postgresql]
[PHP Books]
[PHP Databases]
[PHP SOAP]