Linux上的V8js PHP模块 – 找不到libv8.so

碰到v8js-0.1.2(testing版)的问题 – 我看到其他人在网上已经成功了,但无论我运行的是哪个平台/操作系统,我总是遇到同样的问题。

我目前正在尝试构build模块,直接通过pecl ,并在源代码上使用phpize之后phpize 。 它发现V8安装, configure成功,然后出错:

 /usr/local/src/v8js-0.1.2/v8js.cc: In function 'int zm_startup_v8js(int, int)': /usr/local/src/v8js-0.1.2/v8js.cc:1135: error: 'PHP_V8_VERSION' was not declared in this scope /usr/local/src/v8js-0.1.2/v8js.cc: In function 'void zm_info_v8js(zend_module_entry*)': /usr/local/src/v8js-0.1.2/v8js.cc:1231: error: 'PHP_V8_VERSION' was not declared in this scope make: *** [v8js.lo] Error 1 

如果我在v8js.cc中添加#define PHP_V8_VERSION "0.1.2" ,然后得到:

 /usr/bin/ld: cannot find -lv8 collect2: ld returned 1 exit status make: *** [v8js.la] Error 1 

这是抱怨,因为它不使用提供的V8库path,而是试图findlibv8.so在默认的libpath。 如果我符合它的地方,我得到:

 /usr/bin/ld: skipping incompatible /usr/local/lib/libv8.a when searching for -lv8 /usr/bin/ld: cannot find -lv8 collect2: ld returned 1 exit status make: *** [v8js.la] Error 1 

当libv8.a直接来自新编译的V8。 任何人有任何想法?

附录:我会标记这个v8v8js但我还没有足够的代表呢。 抱歉! 🙁

编辑:

在尝试用library=shared重buildV8(通过scons)后,出现了更多的问题:

 obj/sample/shell/release/shell.o: In function `RunMain(int, char**)': shell.cc:(.text+0xf14): undefined reference to `v8::internal::Thread::Join()' shell.cc:(.text+0xff4): undefined reference to `v8::internal::Thread::Thread(v8::internal::Isolate*, v8::internal::Thread::Options const&)' shell.cc:(.text+0x1008): undefined reference to `v8::internal::Thread::Start()' shell.cc:(.text+0x10a3): undefined reference to `v8::internal::OS::CreateSemaphore(int)' shell.cc:(.text+0x10b2): undefined reference to `v8::internal::OS::CreateSemaphore(int)' obj/sample/shell/release/shell.o: In function `SourceGroup::IsolateThread::~IsolateThread()': shell.cc:(.text._ZN11SourceGroup13IsolateThreadD0Ev[SourceGroup::IsolateThread::~IsolateThread()]+0x14): undefined reference to `v8::internal::Thread::~Thread()' obj/sample/shell/release/shell.o: In function `SourceGroup::IsolateThread::~IsolateThread()': shell.cc:(.text._ZN11SourceGroup13IsolateThreadD1Ev[SourceGroup::IsolateThread::~IsolateThread()]+0xe): undefined reference to `v8::internal::Thread::~Thread()' collect2: ld returned 1 exit status scons: *** [shell] Error 1 scons: building terminated because of errors. 

我应该使用最新版本的V8吗? 此外,如果我保持原样(静态,使用libv8.a),是否有可能使用静态PHP模块呢? 无论什么原因,在v8js-0.1.2源码上运行configure不允许我禁用共享和启用静态; 它们都是默认启用的,并且传递--disabled-shared或者--enable-shared=no (与默认的yes值相反)离开共享启用并禁用静态。

编辑2:

重复编译这个问题的3小时后,似乎是不能启用sample=shell而使用library=shared 。 这似乎并不合理,AFAICT可能是一个bug,然而,使用arch=x64library=shared为我工作,然后我能够链接libv8.so到适当的地方,并编译v8js PHP扩展。

现在的问题是,PHP似乎实际上不能find共享对象:

 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php-5.3.6/lib/php/extensions/no-debug-non-zts-20090626/v8js.so' - libv8.so: cannot open shared object file: No such file or directory in Unknown on line 0 

当libv8.so驻留在/usr/local/v8/libv8.so 。 我已经尝试将该目录追加到$PATH ,将libv8.so链接到扩展目录等。任何想法?

如果在通常位置(直接位于/ usr或/ usr / local)中没有安装V8,configuration脚本可能会很难确定V8的版本。 在运行configuration脚本(–with-v8js = / usr / local / usr / local / mydir / lib) mydir),以便它可以findv8版本。

真的,这是v8js中的一个错误,即configuration脚本无法findV8版本时不会退出1。

你需要libv8.so(共享库,.a通常不是共享库),在/ usr / lib /,/ usr / local / lib /或者在/ etc / ld中指定的任何path。 so.conf(你可以添加你想要的任何目录)