James Wilkins
James Wilkins

Reputation: 7367

Linking V8 Statically

I have a project that works perfectly with V8 dynamically, but I want to embed it statically. I can successfully compile V8 as static, but when I included the resulting libs in my C++ project (which I also changed to static linking), I get errors like this:

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

I have many other errors as well. I've seen some posts mention a v8.lib, but it is not present. There is, however, a v8.obj file.

Any insight would be most welcome, thanks.

Upvotes: 1

Views: 1662

Answers (1)

James Wilkins
James Wilkins

Reputation: 7367

Found the problem. It's actually clearly stated at the top of the v8.h file:

// 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.

I still had 'USING_V8_SHARED' defined. Thanks to @drescherjm for pointing me in the right direction. ;)

Upvotes: 2

Related Questions