How to link required libraries to use google v8 in Visual Studio C++ project -
i’m trying utilize v8 library in visual studio c++ project. not everyday environment may missing obvious.
i think did stated here: https://code.google.com/p/v8/wiki/buildingwithgyp
i.e. checked out next 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 root of v8 project in cmd window ran:
python build\gyp_v8 -dcomponent=static_library -dtarget_arch=x64 -dv8_enable_i18n_support=0 -dv8_use_snapshot=0
…and got:
updating projects 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 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 errors got assume 1 failed 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 using-declaration; expected qualified-name (compiler\machin e-operator-unittest.cc)…
after created new c++ empty project in visual studio. added 1 file source files node 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(); // creating temporary handles utilize handle scope. escapablehandlescope handle_scope(isolate); // create new empty array. local<array> array = array::new(isolate, 3); // homecoming empty result if there error creating array. if (array.isempty()) homecoming local<array>(); // fill out values array->set(0, integer::new(isolate, x)); array->set(1, integer::new(isolate, y)); array->set(2, integer::new(isolate, z)); // homecoming value through escape. homecoming handle_scope.escape(array); } int main(){}
i added path root folder of v8 project checked out before in c/c++ -> general -> additional include directories property (not visual studio project since there no v8 header files there).
i added path build\release\lib folder same v8 project in linker -> general -> additional library directories property. folder contains following:
gmock.lib gtest.lib v8_base.lib v8_libbase.lib v8_libplatform.lib v8_nosnapshot.lib
what should next.
when seek build project in visual studio 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 read this? other posts like:
how compile smallest possible v8 library windows? https://groups.google.com/forum/#!topic/v8-users/khniggixxgm embedding v8 visual c++ 2010
…i got need link libraries.
which ones exactly, why these , how link them in visual studio exactly. of course of study tried different combinations , solutions without positive result.
thanks in advance.
i'm pupil @ school create video game team on course of study of 2 semesters 1 of our classes. we're working on getting v8 integrated @ moment provide scripting capabilities our game engine. we've nail bunch of snags in integrating v8 engine itself, and, depending on when stuff solved, i'll end writing massive blog post either on winter break or summer break. i'll detail how v8 , running in windows application, , more video game.
but in meantime, can tell @ to the lowest degree how got v8 build windows, , how create accessible our game project.
install python 2.x, , create sure added path. if didn't know, can edit path right-clicking , selecting properties of computer/this pc. then, can check path clicking "change settings", going "advanced" tab, , clicking "environment variables". edit "path" variable, , create sure c:\python27
or whatever in there. semicolons separate path entries. also, create sure if have python 3.x installed, not in path. can set later if , need it, remove if exist.
install svn, , create sure added path. super hate svn, unwilling install natively windows, , instead installed part of cygwin bundle. set c:\cygwin64\bin
in path.
figure out you're going have work done, , create new file called v8.cmd there. (cmd files windows batch files, if didn't know.) me, set in root of secondary hard drive, d:. had d:\v8.cmd
.
edit v8.cmd, set next contents of file, save , quit:
svn checkout http://v8.googlecode.com/svn/tags/3.28.57/ v8-build svn checkout http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 v8-build/third_party/cygwin svn checkout http://gyp.googlecode.com/svn/trunk@1831 v8-build/gyp mkdir v8 mkdir v8\lib mkdir v8\lib\release mkdir v8\lib\debug mkdir v8\include phone call "c:\program files (x86)\microsoft visual studio 12.0\common7\tools\vsdevcmd.bat" set cygwin_root=%cd%\v8-build\third_party\cygwin set path=%cygwin_root%\bin;%path% set pythonpath=%cd%\v8-build\gyp\pylib phone call v8-build\third_party\cygwin\setup_mount.bat phone call v8-build\third_party\cygwin\setup_env.bat python v8-build\build\gyp_v8 -dcomponent=static_library -dtarget_arch=ia32 -dv8_enable_i18n_support=0 -dv8_use_snapshot=0 msbuild /m /p:useenv=true /p:configuration=release /p:platform=x86 v8-build\tools\gyp\v8.vcxproj msbuild /m /p:useenv=true /p:configuration=release /p:platform=x86 v8-build\tools\gyp\v8_libplatform.vcxproj msbuild /m /p:useenv=true /p:configuration=release /p:platform=x86 v8-build\tools\gyp\v8_libbase.vcxproj msbuild /m /p:useenv=true /p:configuration=debug /p:platform=x86 v8-build\tools\gyp\v8.vcxproj msbuild /m /p:useenv=true /p:configuration=debug /p:platform=x86 v8-build\tools\gyp\v8_libplatform.vcxproj msbuild /m /p:useenv=true /p:configuration=debug /p:platform=x86 v8-build\tools\gyp\v8_libbase.vcxproj xcopy /y /c "v8-build\build\debug\lib\*.lib" "v8\lib\debug\" xcopy /y /c "v8-build\build\release\lib\*.lib" "v8\lib\release\" xcopy /y /c /s "v8-build\include\*.h" "v8\include\" pause
start administrator command prompt. in windows 8 (and maybe 7?), can right-clicking on start button (or lower-left corner of screen) , clicking command prompt (admin).
navigate location of v8.cmd, , run typing "v8.cmd". several things:
create "v8-build" folder, , check out necessary things svn build library (v8, cygwin v8 needs gyp, , gyp).
create "v8" folder, final stuff project built.
set environment variables necessary run visual studio build scheme script. assuming you're using visual studio 2013.
set environment variables necessary utilize v8 "versions" of cygwin , python.
call batch files more environment variable stuff, don't know, come v8.
run gyp using v8's version of python. generate visual studio project files that, when built, give necessary libraries. (as note: whole thing assuming want statically link v8 project, , not want utilize dlls.)
now it'd cool if build visual studio solution, because that's solutions for, building multiple projects @ time, gyp piece of crap , solutions builds don't work. thus, have build each project want individually. why there 6 separate "msbuild" lines in batch file.
once libraries built, re-create output lib files, necessary header files, v8/ folder.
and we're done!
okay, need include in our project in v8/ folder. now, quick aside how team has our project set up. our solution looks this:
[+] omniarch/ solution root folder | +--[+] include/ folder external library .h files | | | +-- v8.h | +-- v8config.h | +-- v8-debug.h | +-- v8-platform.h | +-- v8-preparser.h | +-- v8-profiler.h | +-- v8stdint.h | +-- v8-testing.h | +-- v8-util.h | +--[+] lib/ folder external library .lib files | | | +--[+] debug/ | | | | | +-- v8_base.lib | | +-- v8_libbase.lib | | +-- v8_libplatform.lib | | +-- v8_nosnapshot.lib | | | +--[+] release/ | | | +-- v8_base.lib | +-- v8_libbase.lib | +-- v8_libplatform.lib | +-- v8_nosnapshot.lib | +--[+] omniarch/ folder "omniarch" project | +--[+] omniengine/ folder "omniengine" project | +-- omniarch.sln solution file
the rest of guide going explain how include v8, assuming folder construction looks this. if don't want yours this, modify stuff accordingly. anyways, re-create contents of v8/ folder solution root folder. if didn't have lib/
, include/
folder before, do, , if did, have more files in them.
in visual studio, right-click on project (the project, not solution), , click properties. create sure box @ top set "all configuration", , not "debug" or "release". under "configuration properties", select "vc++ directories".
at end of "library directories" line, set semicolon, followed by
$(solutiondir)lib;$(solutiondir)lib\$(configuration)
at end of "include directories", set semicolon, followed by
$(solutiondir)include
still in properties page, under "configuration properties" -> "linker" -> "input" -> "additional dependencies" (or "configuration properties" -> "librarian" -> "general" -> "additional dependencies"), add together following, using semicolon if needed:
v8.lib;v8_base.lib;v8_libbase.lib;v8_nosnapshot.lib;v8_libplatform.lib;ws2_32.lib;winmm.lib
if configuration options different debug , release, alter each of , add together above options, instead of overriding both of them.
now should totally ready build. should able to
#include "v8.h"
and have work. , should able build without error.
let me know if helped @ all, , if run problems. spent 4 days banging head against wall create work.
c++ visual-studio-2013 v8
No comments:
Post a Comment