如何链接到v8? [英] How to link against v8?
问题描述
我已成功编译 v8 JavaScript引擎(在Windows上);现在我尝试按照入门文章,但我暂时停留在这一点:
I successfully compiled v8 javascript engine (on windows) ; now I try to follow the Getting started article but I am stuck at this point:
- 编译hello_world.cpp,链接到在构建过程中创建的静态库。
示例是linux(可能是早期版本)。
The example is for linux (and probably for an earlier version).
我试图链接到所有库无法成功:
I tried to link against all libraries that I could without success:
User@PC:/cygdrive/c/Users/Yvain/Documents/depot_tools/v8/build/Release
g++ -std=c++0x -I"C:\Users\Yvain\Documents\depot_tools\v8" -Llib -lv8_libbase -lv8_base_0 -lv8_base_1 -lv8_base_2 -lv8_base_3 -lgmock -lgtest -licui18n -licuuc -lv8_external_snapshot -lv8_libplatform -lv8_nosnapshot hello_world.cpp -o hello_world
它会出现以下错误:
/tmp/ccPxkjlV.o:hello_world.cpp:(.text+0x1a):
undefined reference to « v8::V8::InitializeICU(char const*) »
[...]undefined reference to « v8::V8::InitializeExternalStartupData(char const*) »
[...]
[...]undefined reference to « v8::Isolate::Exit() »
有一个工作示例: v8 / sample / hello-world.vcxproj
但我不明白在项目中指定库的位置。
There is a working example: v8/sample/hello-world.vcxproj
but I don't understand where the libraries are specified in the project.
推荐答案
Visual Studio项目 v8 / sample / hello-world.vcxproj
code> v8 / build / samples / samples.gyp 所有必要的依赖关系。
Visual Studio project v8/sample/hello-world.vcxproj
has been generated with GYP from v8/build/samples/samples.gyp
with all necessary dependencies.
在当前版本的入门文章,在运行示例部分中,项目列表#3包含构建hello_world的命令行示例:
In the current version of "Getting started" article, in "Run example" section, item list #3 contains an example of command line to build the hello_world:
编译hello_world.cpp ,链接到在
中创建的静态库的构建过程。例如,在使用GNU编译器的64位Linux上:
Compile hello_world.cpp, linking to the static libraries created in the build process. For example, on 64bit Linux using the GNU compiler:
g++ -I. hello_world.cpp -o hello_world -Wl,--start-group out/x64.release/obj.target/{tools/gyp/libv8_{base,libbase,external_snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -ldl -pthread -std=c++0x
在Windows上,您需要使用类似的静态库列表作为链接器输入。请注意,这些静态库位于 v8 / build / Release / lib
目录中。
On Windows you need to use the similar list of static libraries as a linker input. Please note these static libraries are placed in v8/build/Release/lib
directory.
这篇关于如何链接到v8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!