簡體   English   中英

鏈接V8時未定義的引用

[英]undefined reference when linking V8

我很勉強用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 test -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

基本庫,快照庫和無快照庫文件之間究竟有什么區別? 我嘗試過連接它們,但它們都不起作用:/

首先,我要為我糟糕的英語道歉。 我剛剛將.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,快照} .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”

希望對大家有所幫助〜作為一個中國人,對不起我的英語。

編譯行:
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

此鏈接行不正確。 試試這個:

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

閱讀本文以了解訂單的重要性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM