Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building and Linking V8 in Visual Studio

I'm having a really hard time trying to figure out how to build Google's V8 on Windows.

So far I have:

  • Installed depot_tools
  • Fetched v8: fetch v8
  • Created the project files: gn gen --ide=vs2015 out/Default
  • Built the entire solution in VS2015

My issue is that this only produces a large number of .obj files and no .lib files.

I have set the projects (v8, v8_base, v8_libbase, etc.) to Configuration type: Static library (.lib): Project config screenshot

I'm not sure how to get Visual Studio to generate the library files. Any help appreciated!

Update

I have managed to produce library files using the following steps:

  • Open VS Developer Command Line
  • Navigate to the directories containing obj files for v8_base, v8_libbase, v8_external_snapshot and v8_libplatform.
  • For each of these, build a .lib manually using the lib command e.g. lib /o:v8_base *.obj
  • Copy all these lib files into a directory along with icui18n.lib and icuuc.lib (these were created fine during the build.)

I'm now trying to actually use the libraries and have a new problem which I would appreciate help with. I have linked the following libraries in VS: v8_base.lib; v8_libbase.lib; v8_external_snapshot.lib; v8_libplatform.lib; icui18n.lib; icuuc.lib; winmm.lib;, however I am having an issue with a few unresolved symbols:

unresolved external symbol "public: static void __cdecl v8::sampler::Sampler::TearDown(void)" (?TearDown@Sampler@sampler@v8@@SAXXZ) referenced in function "public: static void __cdecl v8::internal::V8::TearDown(void)" (?TearDown@V8@internal@v8@@SAXXZ) TriviaBot   v8_base.lib(v8.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Stop(void)" (?Stop@Sampler@sampler@v8@@QEAAXXZ) referenced in function "private: void __cdecl v8::internal::Isolate::Deinit(void)" (?Deinit@Isolate@internal@v8@@AEAAXXZ) v8_base.lib(isolate.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Stop(void)" (?Stop@Sampler@sampler@v8@@QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: __cdecl v8::sampler::Sampler::Sampler(class v8::Isolate *)" (??0Sampler@sampler@v8@@QEAA@PEAVIsolate@2@@Z) referenced in function "public: __cdecl v8::internal::Ticker::Ticker(class v8::internal::Isolate *,int)" (??0Ticker@internal@v8@@QEAA@PEAVIsolate@12@H@Z) v8_base.lib(log.obj)   
unresolved external symbol "public: __cdecl v8::sampler::Sampler::Sampler(class v8::Isolate *)" (??0Sampler@sampler@v8@@QEAA@PEAVIsolate@2@@Z) v8_base.lib(cpu-profiler.obj)    
unresolved external symbol "public: virtual __cdecl v8::sampler::Sampler::~Sampler(void)" (??1Sampler@sampler@v8@@UEAA@XZ) referenced in function "public: virtual void * __cdecl v8::internal::Ticker::`scalar deleting destructor'(unsigned int)" (??_GTicker@internal@v8@@UEAAPEAXI@Z)
unresolved external symbol "public: virtual __cdecl v8::sampler::Sampler::~Sampler(void)" (??1Sampler@sampler@v8@@UEAA@XZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Start(void)" (?Start@Sampler@sampler@v8@@QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Engage(void)" (?Engage@Profiler@internal@v8@@QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::IncreaseProfilingDepth(void)" (?IncreaseProfilingDepth@Sampler@sampler@v8@@QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Engage(void)" (?Engage@Profiler@internal@v8@@QEAAXXZ)   v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::IncreaseProfilingDepth(void)" (?IncreaseProfilingDepth@Sampler@sampler@v8@@QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DecreaseProfilingDepth(void)" (?DecreaseProfilingDepth@Sampler@sampler@v8@@QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Disengage(void)" (?Disengage@Profiler@internal@v8@@QEAAXXZ) v8_base.lib(log.obj)    
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DecreaseProfilingDepth(void)" (?DecreaseProfilingDepth@Sampler@sampler@v8@@QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DoSample(void)" (?DoSample@Sampler@sampler@v8@@QEAAXXZ) referenced in function "public: virtual void __cdecl v8::internal::SamplingThread::Run(void)" (?Run@SamplingThread@internal@v8@@UEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DoSample(void)" (?DoSample@Sampler@sampler@v8@@QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: static void __cdecl v8::sampler::Sampler::SetUp(void)" (?SetUp@Sampler@sampler@v8@@SAXXZ) referenced in function "private: static void __cdecl v8::internal::V8::InitializeOncePerProcessImpl(void)" (?InitializeOncePerProcessImpl@V8@internal@v8@@CAXXZ) v8_base.lib(v8.obj)

All of the error seem to be related to v8::sampler - any help is again appreciated!

like image 470
Jack Avatar asked Jul 30 '16 13:07

Jack


2 Answers

And it looks like I'm answering my own question again. I hope the info I listed in the question will be useful for anyone who struggles with the out-of-date documentation like me.

My update covers everything required except for the fact I didn't even notice the v8_libsampler project and forgot to generate the library file for it. Once I did that and linked it, I was up and running!

like image 127
Jack Avatar answered Nov 17 '22 02:11

Jack


Just like you, I was trying different settings to get the lib building. And here are my steps:

  1. After gn gen, run gn args out/Default, uncomment is_component_build, that's the equivalent of component=shared_library I guess.
  2. While I also have problem building all.sln in vs.net I realized msbuild can give me some of the dll/lib files.

Good luck.

like image 1
user902590 Avatar answered Nov 17 '22 00:11

user902590