静态链接V8

Linking V8 Statically

本文关键字:V8 链接 静态      更新时间:2023-10-16

我有一个动态地与V8完美配合的项目,但我想静态地嵌入它。我可以成功地将V8编译为静态,但当我将生成的库包含在C++项目中时(我也将其更改为静态链接),我会收到这样的错误:

Error   12  error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall v8::HandleScope::HandleScope(class v8::Isolate *)" (__imp_??0HandleScope@v8@@QAE@PAVIsolate@1@@Z)

我还有许多其他错误。我看到一些帖子提到v8.lib,但它并不存在。但是,有一个v8.obj文件。

任何见解都将是最受欢迎的,谢谢。

发现问题。它实际上在v8.h文件的顶部有明确的说明:

// Setup for Windows DLL export/import. When building the V8 DLL the
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
// static library or building a program which uses the V8 static library neither
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.

我仍然定义了"USING_V8_SHARED"。感谢@drescherjm为我指明了正确的方向。)