I would like to add some more information to this topic. It could be useful to someone later. The previous version of V8 I am using is about a year old now and I would like to debug javascript in the embedded vm that is why I need the latest version.
I struggled a lot to make it work. I did not managed to create the necessary static libs. First I linked the obj files. It was a working but ugly solution. Then I found this topic that led me to the "proper" solution.
I had to have the static libs with statically linked runtime.
Here are the steps that worked for me:
download and unzip
https://storage.googleapis.com/chrome-infra/depot_tools.zip to a folder (e.g. d:\Dev\v8-3\depot_tools)
prepend (not append!) depot_tools to PATH:> path=d:\Dev\v8-3\depot_tools;%PATH%
> gclient
> set DEPOT_TOOLS_WIN_TOOLCHAIN=0
> fetch v8
> cd v8
(if the next step does not work reinstall Win SDK 10 (maybe just the debugging tools from it suffices))
> gn gen --args="is_debug=false is_component_build=false v8_use_snapshot=true v8_use_external_startup_data=false v8_static_library=true" --ide=vs out\Default
> call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
> msbuild out\Default\all.sln /nologo /t:Build /p:Configuration=GN,Platform=x64 /v:normal
Three things to highlight
1. The "shard" feature seems to have disappeared. The v8_base.lib is 0.4G in release.
2. v8_libsampler.lib, DbgHelp.lib and Shlwapi.lib should probably be linked to the project to avoid unresolved external references
3. I had to change BUILD.gn to sort out several project failures caused by the referenced but not created wasm_test_signatures.lib:
v8_source_set("wasm_test_signatures") {
sources = [
"test/common/wasm/test-signatures.cc", #this is new
"test/common/wasm/test-signatures.h",
]
configs = [
":external_config",
":internal_config_base",
]
}
I also added a new file "test/common/wasm/test-signatures.cc". This file is only one line, it includes test/common/wasm/test-signatures.h.
After these changes gn gen generated the correct project file (wasm_test_signatures.vcxproj) that created the missing wasm_test_signatures.lib. (Interestingly "msbuild out\Default2\obj\wasm_test_signatures.vcxproj /nologo /t:Build /p:Configuration=GN,Platform=x64 /v:normal" did not fail but it did not create the lib, either)
And finally this is how I link V8 to my project on Windows:
#if defined(_WIN32)
# //define V8_SHARD
# define V8_SNAPSHOT
# //define V8_EXTERNAL_SNAPSHOT
# if defined(V8_SHARD)
# pragma comment(lib, "v8_base_0.lib")
# pragma comment(lib, "v8_base_1.lib")
# pragma comment(lib, "v8_base_2.lib")
# pragma comment(lib, "v8_base_3.lib")
# else
# pragma comment(lib, "v8_base.lib")
# endif //V8_SHARD
# pragma comment(lib, "v8_libbase.lib")
# pragma comment(lib, "v8_libplatform.lib")
# pragma comment(lib, "v8_libsampler.lib")
# pragma comment(lib, "icui18n.lib")
# pragma comment(lib, "icuuc.lib")
# pragma comment(lib, "winmm.lib")
# pragma comment(lib, "DbgHelp.lib")
# pragma comment(lib, "Shlwapi.lib")
# if defined(V8_SNAPSHOT)
# if defined(V8_EXTERNAL_SNAPSHOT)
# pragma comment(lib, "v8_external_snapshot.lib")
# else
# pragma comment(lib, "v8_snapshot.lib")
# endif
# else
# pragma comment(lib, "v8_nosnapshot.lib")
# endif //V8_SNAPSHOT
#endif //_WIN32
This is a the version I built: bfa425cc0841f17294e933e8d3611aad42deb2ee (Tue Feb 28 07:31:08 2017 -0800)
The problem with wasm_test_signatures.lib seems to be a bug. Could someone please confirm and fix it?
Is there a document that describes how to link V8 to projects? It can be quite a daunting job to upgrade it from an older version.