在Visual Studio中构建和链接V8

时间:2016-07-30 13:51:40

标签: c++ visual-studio build visual-studio-2015 v8

我正在努力弄清楚如何在Windows上构建Google的V8。

到目前为止,我有:

  • 已安装depot_tools
  • 获取v8:fetch v8
  • 创建了项目文件:gn gen --ide=vs2015 out/Default
  • 在VS2015中构建整个解决方案

我的问题是,这只会产生大量.obj个文件,而不会产生.lib个文件。

我已将项目(v8,v8_base,v8_libbase等)设置为Configuration type: Static library (.lib)Project config screenshot

我不确定如何让Visual Studio生成库文件。任何帮助表示赞赏!

更新

我已设法使用以下步骤生成库文件:

  • 打开VS Developer命令行
  • 导航到包含v8_basev8_libbasev8_external_snapshotv8_libplatform的obj文件的目录。
  • 对于其中每一项,请使用.lib命令手动构建lib,例如lib /o:v8_base *.obj
  • 将所有这些lib文件与icui18n.libicuuc.lib一起复制到一个目录中(这些在构建期间创建得很好。)

我现在正试图实际使用这些库并遇到一个新问题,我将不胜感激。 我在VS中链接了以下库:v8_base.lib; v8_libbase.lib; v8_external_snapshot.lib; v8_libplatform.lib; icui18n.lib; icuuc.lib; winmm.lib;,但是我遇到了一些未解决的符号问题:

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)

所有错误似乎与v8::sampler有关 - 再次感谢任何帮助!

3 个答案:

答案 0 :(得分:2)

看起来我又回答了自己的问题。我希望我在问题中列出的信息对于那些与我这样的过时文档挣扎的人都有用。

我的更新涵盖了所有必需的内容,除了我甚至没有注意到v8_libsampler项目并忘记为其生成库文件这一事实。一旦我这样做并将其链接起来,我就开始运行了!

答案 1 :(得分:1)

就像你一样,我正在尝试不同的设置来获得lib构建。这是我的步骤:

  1. 在gn gen之后,运行gn args out / Default,取消注释is_component_build,我认为这相当于component = shared_library。
  2. 虽然我在vs.net中构建all.sln也有问题,但我意识到msbuild可以给我一些dll / lib文件。
  3. 祝你好运。

答案 2 :(得分:0)

我已经完成了类似的配置,但对于VS2013和运行忍者来构建一切。 Build已经产生了我的一组DLL,包括v8.dll,我完全没问题。