谷歌决定弃用V8的gyp版本。推荐的方法是使用gn。
构建但是,PHP扩展v8js无法找到所需的库并退出:
checking for V8 Javascript Engine... yes, shared
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for C standard version... c++11
checking how to allow c++11 narrowing... -Wno-narrowing
checking for V8 version... NONE
configure: error: could not determine libv8 version
使用gn?
编译V8后,需要做些什么才能编译PHP v8js扩展谢谢!
答案 0 :(得分:2)
经过两天的实验,我成功地编译了v8的v8js,这是用gn构建的(而不是现在弃用的gyp)。
按照初始结帐说明https://github.com/v8/v8/wiki/Building%20with%20GN。
tools/dev/v8gen.py x64.release
步后执行此操作:
$ nano out.gn/x64.release/args.gn
看起来应该是这样的:
is_debug = false
target_cpu = "x64"
is_component_build = true
v8_enable_i18n_support = false
此时我无法弄清楚如何正确构建i18n支持。
不确定这是否真的需要,但我还更新了out.gn/x64.release/v8_build_config.json
:“v8_enable_i18n_support”:false 。
编译(大约需要45分钟):
$ ninja -C out.gn/x64.release
编译完成后:
$ cp out.gn/x64.release/lib*.so /usr/lib/ && cp -R include/* /usr/include
$ cp out.gn/x64.release/natives_blob.bin /usr/lib
$ cp out.gn/x64.release/snapshot_blob.bin /usr/lib
$ cd out.gn/x64.release/obj
$ ar rcsDT libv8_libplatform.a v8_libplatform/*.o
$ echo -e "create /usr/lib/libv8_libplatform.a\naddlib /usr/local/src/v8/out.gn/x64.release/obj/libv8_libplatform.a\nsave\nend" | sudo ar -M
之后检查v8js并像往常一样编译:
phpize
./configure
make && make install
答案 1 :(得分:0)
echo -e“创建/usr/lib/libv8_libplatform.a\naddlib /usr/local/src/v8/out.gn/x64.release/obj/libv8_libplatform.a\nsave\nend须藤ar -M
print: /usr/local/src/v8/out.gn/x64.release/obj/libv8_libplatform.a:没有这样的文件或目录