我正在努力用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基本文件、快照文件和无快照库文件之间到底有什么区别?我尝试过链接每一个,但都不起作用:/
发布于 2013-10-30 20:08:51
首先,我得为我糟糕的英语说声抱歉。我刚刚将.a文件链接到我自己的项目。由于未提供libv8_snapshot.a的依赖关系,因此出现% ld错误。
这是我的编译语句:
快照~v8/out/native/obj.target/tools/gyp/libv8_{base.native,~v8/out/native/obj.target/third_party/icu/libicu{data,~v8/out/native/obj.target/icudata/third_party/icu/linux/icudt46_dat.o g++ -o xxxxx -I .a~v8/out/native/obj.target/third_party/icu/libicu{data,-lrt -lpthread }.a xxxxx快照
我认为libv8_base.native.a libv8_snapshot.a依赖于icu和icudt46文件,而unix clock_time的一些功能是依赖于rt的,所以加上"-lrt“。
希望对大家有所帮助~作为一个中国人,很抱歉我的英语。
发布于 2013-02-28 10:47:14
编译行:
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请阅读this以了解为什么顺序很重要。
https://stackoverflow.com/questions/15071432
复制相似问题