2014-02-28 124 views
1

我读了V8 hello world示例,并按照文档中的步骤成功构建v8。v8 hello world示例链接错误

但是,当我编译示例代码,链接错误发生。这里是我的电脑详细信息和错误提示。

  1. OS的Ubuntu 13.10 AMD64
  2. GCC(Ubuntu的/ Linaro的4.8.1-10ubuntu9)4.8.1
  3. 编译命令:
g++ -Iinclude hello_world.cc -o hello_world -Wl,--start-group out/native/obj.target/{tools/gyp/libv8_{base.x64,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt 

错误提示

/usr/bin/ld: /home/leon/Documents/v8/v8/out/native/obj.target/v8_base.x64/src/platform/mutex.o: undefined reference to symbol '[email protected]@GLIBC_2.2.5' 
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 

回答

4

错误提示您需要将pthread库添加到链接命令中。只需追加-lpthread

(这是一个有点古怪,它标识正是你所需要的库,然后告诉你它拒绝使用它,因为你没有列出它的命令行...)

+0

它炒菜。谢谢 – tinyproxy

+0

对于那些被链接器错误困惑的人,“DSO”代表动态共享对象。 – Garrett