链接V8时未定义的引用
undefined reference when linking V8
我正在努力用V8.编译一个非常小的例子
cpp程序是这样的:
#include "v8.h"
int main()
{
v8::HandleScope handle_scope;
return 0;
}
编译行:g++-I/home/alterje/git/tengine/Externals/v8/include/home/alternje/git/tengine/Eexternals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.atest.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/nature/obj.target/tools/gyp/libv8_{base.nature,snapshot}.a~v8/out/nature/obj.target_third_party/icu/libicu{data,i18n,snapshot}.a~v8/1out/naturt/obj.ttarget/icudata/third_paarty/icu/linux/icudt46_dat.o-lrt-lpthread
我认为libv8_base.natur.a libv8_snapshot.a依赖于icu和icudt46文件,并且unix clock_time的一些函数依赖于"rt",所以添加"-lrt">
希望对大家有所帮助~作为一个中国人,对不起我的英语。
编译行:
g++-I/home/alterje/git/tengine/Externals/v8/include/home/alternje/git/tengine/Eexternals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.atest.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
阅读此内容,了解订单为何重要。
- 编译C++时未定义的引用
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 未定义的引用在哪里
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 对 Scalar ::Scalar() 的未定义引用
- 已定义函数时出现 G++ "未定义的引用"错误
- 链接 cmake 时出现未定义的引用错误
- 对复制 CTOR 和 CTOR 的未定义引用
- 错误:未定义对'oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)'的引用
- 右值引用未定义的行为
- 对"vtable for DigitalClock"的未定义引用 - 未定义对"DigitalClock::staticMetaObject"的引用 - Qt
- 函数类型到函数类型的引用:未定义的引用
- avcodec_alloc_context引用未定义,但ffmpeg链接顺序正确
- 从c++调用Fortran子程序,链接时引用未定义
- 枚举引用未定义,但位于包含的头文件中