0

我正在努力用 V8 编译一个非常小的示例 ..

cpp程序是这样的:

#include "v8.h"

int main()
{
     v8::HandleScope handle_scope;

     return 0;
}

编译行:g++ -I/home/lterje/git/tengine/Externals/v8/include /home/lterje/git/tengine/Externals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a test.cpp -o 测试 -lpthread

我得到的错误:

/tmp/ccHYtJuE.o: In function `main':
test.cpp:(.text+0x11): undefined reference to `v8::HandleScope::HandleScope()'
test.cpp:(.text+0x22): undefined reference to `v8::HandleScope::~HandleScope()'
collect2: error: ld returned 1 exit status

基本、快照和无快照库文件之间到底有什么区别?我已经尝试与它们中的每一个链接,但它们都不起作用:/

4

2 回答 2

2

first I have to say sorry for my poor english. I have just link the .a file to my own project. There's ld error because of the dependencies of the libv8_snapshot.a is not been given.

This is my compile statement:

g++ -o xxxxx -I ~v8/out/native/obj.target/tools/gyp/libv8_{base.native,snapshot}.a ~v8/out/native/obj.target/third_party/icu/libicu{data,i18n,snapshot}.a ~v8/out/native/obj.target/icudata/third_party/icu/linux/icudt46_dat.o -lrt -lpthread

I think that the libv8_base.native.a libv8_snapshot.a is dependend on icu and icudt46 files and thereis some functions about unix clock_time is dependend on "rt", so add "-lrt"

Hope helpful for you all~ As a Chinese,sorry for my english.

于 2013-10-30T12:08:50.887 回答
0

编译行:
g++ -I/home/lterje/git/tengine/Externals/v8/include /home/lterje/git/tengine/Externals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a test.cpp -o 测试 -lpthread

此链接线不正确。试试这个:

g++ -I/home/lterje/git/tengine/Externals/v8/include \
  test.cpp -o test \
  /home/.../obj.target/tools/gyp/libv8_snapshot.a \
  -lpthread

阅读本文以了解订单为何重要。

于 2013-02-28T02:47:13.577 回答