I'm writing an extension called "V8PHP". It's similar to the V8JS extension,
but the implementation is quite different.
I'm having trouble linking the v8 library to my extension. When I run a PHP
script via CLI I get:
dyld: lazy symbol binding failed: Symbol not found: __ZN2v86String3NewEPKci
Referenced from: /phpdev/lib/php/extensions/debug-zts-20090626/v8php.so
Expected in: flat namespace
dyld: Symbol not found: __ZN2v86String3NewEPKci
Referenced from: /phpdev/lib/php/extensions/debug-zts-20090626/v8php.so
Expected in: flat namespace
Trace/BPT trap
I have PHP installed in /phpdev/ (--prefix=/phpdev). v8 was compiled with
gyp using the following commands:
cd /v8/
make dependencies
make native
And this outputted these files to /v8/out/native/:
libpreparser_lib.a
libv8_base.a
libv8_nosnapshot.a
libv8_snapshot.a
obj/
obj.target/
And the obj.target directory has a bunch of .a files in
obj.target/v8_base/src/.
I created a soft link from /v8/include/v8.h to /phpdev/include/v8.h,
/v8/include/v8stdint.h to /phpdev/include/v8stdint.h, and
/v8/out/native/libv8_base.a to /phpdev/lib/libv8.a.
My config.m4 file looks like this:
PHP_ARG_ENABLE(v8php,
[V8PHP],
[--enable-v8php Include V8 JavaScript Engine])
if test $PHP_V8PHP != "no"; then
SEARCH_PATH="$prefix /usr/local /usr"
SEARCH_FOR="/include/v8.h"
if test -r $PHP_V8PHP/$SEARCH_FOR; then
V8_DIR=$PHP_V8PHP
else
AC_MSG_CHECKING([for V8 files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
V8_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$V8_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Unable to locate V8])
fi
PHP_ADD_INCLUDE($V8_DIR/include)
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8PHP_SHARED_LIBADD)
PHP_SUBST(V8PHP_SHARED_LIBADD)
PHP_REQUIRE_CXX()
PHP_NEW_EXTENSION(v8php, v8php.cc v8_class.cc, $ext_shared)
fi
It _seems_ like libv8.a is trying to link to something else... but I'm not
sure. My extension compiled fine.
I'm on Mac OS X 10.6.x.
Anyone know what the problem could be?
Luke