I’m trying to use v8 library in another Visual Studio C++ project. It is not my everyday environment so I may be missing something obvious.
I think I did everything as it is stated here:
https://code.google.com/p/v8/wiki/BuildingWithGYP
i.e.
checked out the following repos:
svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26 third_party/python_26 --revision 89111
svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin third_party/cygwin --revision 66844
svn co https://src.chromium.org/chrome/trunk/deps/third_party/icu52 third_party/icu --revision 277999
svn co http://googletest.googlecode.com/svn/trunk testing/gtest --revision 643
svn co http://googlemock.googlecode.com/svn/trunk testing/gmock --revision 410
Then from the root of the v8 project in the cmd window I ran:
python build\gyp_v8 -Dcomponent=static_library -Dtarget_arch=x64 -Dv8_enable_i18n_support=0 -Dv8_use_snapshot=0
…and got:
Updating projects from gyp files...
Warning: Missing input files:
C:\...\v8\tools\gyp\..\..\src\uri.h
C:\...\v8\tools\gyp\..\..\src\feedback-slots.h
Running build/landmines.py...
Next I ran:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" /build Release build\All.sln
…and got:
(...)
19>------ Build started: Project: All, Configuration: Release x64 ------
========== Build: 18 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From the errors I got I assume that the one that failed is the test project:
…18>C:\...\v8\testing\gtest\include\gtest/internal/
gtest-param-util.h(393): error C2868: 'testing::internal::TestMetaFactory<v8::in
ternal::compiler::MachineStoreOperatorTest_ParameterIsCorrect_Test>::ParamType'
: illegal syntax for using-declaration; expected qualified-name (compiler\machin
e-operator-unittest.cc)…
After this I created new C++ Empty project in Visual Studio. Added one file to the Source Files node with this sample content:
#include <include\v8.h>
#include <include\libplatform\libplatform.h>
using namespace v8;
Local<Array> NewPointArray(int x, int y, int z) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// We will be creating temporary handles so we use a handle scope.
EscapableHandleScope handle_scope(isolate);
// Create a new empty array.
Local<Array> array = Array::New(isolate, 3);
// Return an empty result if there was an error creating the array.
if (array.IsEmpty())
return Local<Array>();
// Fill out the values
array->Set(0, Integer::New(isolate, x));
array->Set(1, Integer::New(isolate, y));
array->Set(2, Integer::New(isolate, z));
// Return the value through Escape.
return handle_scope.Escape(array);
}
int main(){}
I added path to the root folder of the v8 project I checked out earlier in the C/C++ -> General -> Additional Include Directories property (not to the Visual Studio project since there are no v8 header files there).
I also added path to the build\Release\lib folder from the same v8 project in the Linker -> General -> Additional Library Directories property. This folder contains following:
gmock.lib
gtest.lib
v8_base.lib
v8_libbase.lib
v8_libplatform.lib
v8_nosnapshot.lib
What should I do next.
When I try to build the project in the Visual Studio I get:
1>------ Build started: Project: SOProject, Configuration: Debug Win32 ------
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall v8::HandleScope::~HandleScope(void)" (??1HandleScope@v8@@QAE@XZ) referenced in function "public: __thiscall v8::EscapableHandleScope::~EscapableHandleScope(void)" (??1EscapableHandleScope@v8@@QAE@XZ)
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall v8::EscapableHandleScope::EscapableHandleScope(class v8::Isolate *)" (??0EscapableHandleScope@v8@@QAE@PAVIsolate@1@@Z) referenced in function "class v8::Local<class v8::Array> __cdecl NewPointArray(int,int,int)" (?NewPointArray@@YA?AV?$Local@VArray@v8@@@v8@@HHH@Z)
1>Source.obj : error LNK2019: unresolved external symbol "private: class v8::internal::Object * * __thiscall v8::EscapableHandleScope::Escape(class v8::internal::Object * *)" (?Escape@EscapableHandleScope@v8@@AAEPAPAVObject@internal@2@PAPAV342@@Z) referenced in function "public: class v8::Local<class v8::Array> __thiscall v8::EscapableHandleScope::Escape<class v8::Array>(class v8::Local<class v8::Array>)" (??$Escape@VArray@v8@@@EscapableHandleScope@v8@@QAE?AV?$Local@VArray@v8@@@1@V21@@Z)
1>Source.obj : error LNK2019: unresolved external symbol "public: static class v8::Local<class v8::Integer> __cdecl v8::Integer::New(class v8::Isolate *,int)" (?New@Integer@v8@@SA?AV?$Local@VInteger@v8@@@2@PAVIsolate@2@H@Z) referenced in function "class v8::Local<class v8::Array> __cdecl NewPointArray(int,int,int)" (?NewPointArray@@YA?AV?$Local@VArray@v8@@@v8@@HHH@Z)
1>Source.obj : error LNK2019: unresolved external symbol "public: bool __thiscall v8::Object::Set(unsigned int,class v8::Handle<class v8::Value>)" (?Set@Object@v8@@QAE_NIV?$Handle@VValue@v8@@@2@@Z) referenced in function "class v8::Local<class v8::Array> __cdecl NewPointArray(int,int,int)" (?NewPointArray@@YA?AV?$Local@VArray@v8@@@v8@@HHH@Z)
1>Source.obj : error LNK2019: unresolved external symbol "public: static class v8::Local<class v8::Array> __cdecl v8::Array::New(class v8::Isolate *,int)" (?New@Array@v8@@SA?AV?$Local@VArray@v8@@@2@PAVIsolate@2@H@Z) referenced in function "class v8::Local<class v8::Array> __cdecl NewPointArray(int,int,int)" (?NewPointArray@@YA?AV?$Local@VArray@v8@@@v8@@HHH@Z)
1>Source.obj : error LNK2019: unresolved external symbol "public: static class v8::Isolate * __cdecl v8::Isolate::GetCurrent(void)" (?GetCurrent@Isolate@v8@@SAPAV12@XZ) referenced in function "class v8::Local<class v8::Array> __cdecl NewPointArray(int,int,int)" (?NewPointArray@@YA?AV?$Local@VArray@v8@@@v8@@HHH@Z)
1>D:\PROGRAMMING\!VisualStudioProjects\SOProject\Debug\SOProject.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How should I read this? From other posts like:
How to compile the smallest possible V8 library for Windows?
https://groups.google.com/forum/#!topic/v8-users/KhniGgixxGM
Embedding v8 with Visual C++ 2010
…I got that I need to link another libraries.
Which ones exactly, why these and how do I link them in Visual Studio exactly. Of course I tried different combinations and solutions but without any positive result.
Thanks in advance.