链接V8时的未定义参考 [英] undefined reference when linking V8

查看:133
本文介绍了链接V8时的未定义参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pre> #includev8.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 test -lpthread



我得到的错误:

  /tmp/ccHYtJuE.o: 
test.cpp :(。text + 0x11):未定义的引用`v8 :: HandleScope :: HandleScope()'
test.cpp :(。 :HandleScope ::〜HandleScope()'
collect2:error:ld返回1退出状态

基础,快照和快照库文件之间的区别究竟是什么?我试过链接每个人,但没有一个工作:/

解决方案

可怜的英语。
我只是将.a文件链接到我自己的项目。
由于libv8_snapshot.a的依赖关系没有给出,因此有ld错误。



这是我的编译语句:



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



我认为libv8_base.native.a libv8_snapshot.a是依赖于icu和icudt46文件,有一些关于unix clock_time的函数是依赖于rt,所以添加-lrt



希望对你有帮助〜
作为中文,对不起我的英语。


I'm strugling to compile a really small example with V8..

cpp program is this:

#include "v8.h"

int main()
{
     v8::HandleScope handle_scope;

     return 0;
}

Compile line: 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 test -lpthread

Error I'm getting:

/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

What exactly is the difference between the base, snapshot and no snapshot library files? I've tried linking with each of them, but none of them works :/

解决方案

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.

这篇关于链接V8时的未定义参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆