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.

On Friday, 18 November 2016 17:22:55 UTC, Ivan P. wrote:
>
> Found solution. So just if someone needs- 
> 1. update v8/gni/v8.gni, put static library 
> template("v8_source_set") {
>   static_library(target_name) {
> 2. generate build files with gn
> 3. Run ninja -j1 -C yourbuilddir d8
> Build only d8 - this will build all necessary libs.  
> Then pick yourbuilddir/obj/*.lib and following
> yourbuilddir/icuuc.dll
> yourbuilddir/icuuc.dll.lib
> yourbuilddir/icuuc.dll.pdb
> yourbuilddir/icui18n.dll
> yourbuilddir/icui18n.dll.lib
> yourbuilddir/icui18n.dll.pdb
> yourbuilddir/icudtl.dat
> Link with all libs from picked, except you need to select between 
> v8_nosnaphshot.lib or v8_external_snapshot.lib depending on what you need.
> Hoping that this will be helpful for someone else.
>
> 2016-11-18 2:24 GMT+02:00 Ivan Pizhenko <[email protected] <javascript:>
> >:
>
>> Found workaround, but still have problem!
>> Workaround: building as ninja -j1 -C out.gn/optdebug.x64 d8
>> This seems to build everything necessary.
>> Then added following libs to linker options:
>> icui18n.lib
>> icuuc.lib
>> v8_base.lib
>> v8_external_snapshot.lib
>> v8_libbase.lib
>> v8_libplatform.lib
>> v8_libsampler.lib
>>
>> So building now as static lib, but still have issue:
>>
>> Many errors like this (pasting here one instance of each):
>>
>> 1>v8_base.lib(api.obj) : error LNK2038: mismatch detected for 
>> 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 
>> 'MDd_DynamicDebug' in application.obj
>>
>> 1>v8_base.lib(preparser.obj) : error LNK2001: unresolved external symbol 
>> "void (__cdecl* std::_Raise_handler)(class stdext::exception const &)" 
>> (?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA)
>>
>> 1>icuuc.lib(messagepattern.obj) : error LNK2005: "public: __cdecl 
>> std::_Container_base12::_Container_base12(void)" 
>> (??0_Container_base12@std@@QEAA@XZ) already defined in 
>> msvcprtd.lib(MSVCP120D.dll)
>>
>> 1>v8_base.lib(type-hint-analyzer.obj) : error LNK2001: unresolved 
>> external symbol "__int64 const std::_BADOFF" (?_BADOFF@std@@3_JB)
>>
>> 1>v8_base.lib(bytecode-peephole-optimizer.obj) : error LNK2001: 
>> unresolved external symbol "private: static int std::locale::id::_Id_cnt" 
>> (?_Id_cnt@id@locale@std@@0HA)
>>
>> 1>v8_base.lib(bytecode-array-builder.obj) : error LNK2001: unresolved 
>> external symbol "public: static class std::locale::id std::ctype<char>::id" 
>> (?id@?$ctype@D@std@@2V0locale@2@A)
>>
>> 1>v8_base.lib(simplified-lowering.obj) : error LNK2001: unresolved 
>> external symbol _Nan
>>
>> My app in the configuration I am building (sort of "Debug") is linking to 
>> dynamic debug CRT, and I am generally expect that V8 built statically will 
>> be linking to that too, but seems like this is not the case.
>> Please advise, what to change  else in the GN configs to get it working? 
>>
>> 2016-11-16 18:47 GMT+02:00 Ivan Pizhenko <[email protected] 
>> <javascript:>>:
>>
>>> Content of RSP file
>>>
>>> obj/build/win/default_exe_manifest/default_exe_manifest.manifest.res
>>> obj/json_fuzzer.lib
>>> obj/simple_fuzzer.lib
>>> obj/fuzzer_support.lib
>>> obj/v8_libplatform.lib
>>> obj/v8_libbase.lib
>>> obj/v8_external_snapshot.lib
>>> obj/v8_base.lib
>>> obj/v8_libsampler.lib
>>> obj/third_party/icu/icui18n.lib
>>> obj/third_party/icu/icuuc.lib advapi32.lib comdlg32.lib dbghelp.lib 
>>> delayimp.lib dnsapi.lib gdi32.lib kernel32.lib msimg32.lib odbc32.lib 
>>> odbccp32.lib ole32.lib oleaut32.lib psapi.lib shell32.lib shlwapi.lib 
>>> user32.lib usp10.lib uuid.lib version.lib wininet.lib winmm.lib 
>>> winspool.lib ws2_32.lib  /DEBUG /MACHINE:X64 /FIXED:NO /ignore:4199 
>>> /ignore:4221 /NXCOMPAT /maxilksize:0x7ff00000 /fastfail /DYNAMICBASE:NO 
>>> /INCREMENTAL /SUBSYSTEM:CONSOLE,5.02 /STACK:2097152 /LIBPATH:"C:/Program 
>>> Files (x86)/Windows Kits/10/Lib/winv6.3/um/x64" /LIBPATH:"C:/Program Files 
>>> (x86)/Microsoft Visual Studio 12.0/VC/lib/amd64" /LIBPATH:"C:/Program Files 
>>> (x86)/Microsoft Visual Studio 12.0/VC/atlmfc/lib/amd64"
>>>
>>> 2016-11-16 18:45 GMT+02:00 Ivan Pizhenko <[email protected] 
>>> <javascript:>>:
>>>
>>>> Edited gni/v8.gni as you recommended and trying to build with following 
>>>> args.gn:
>>>>
>>>> is_component_build = false
>>>> is_debug = true
>>>> v8_optimized_debug=false
>>>> target_cpu="x64"
>>>> v8_target_cpu="x64"
>>>>
>>>> and getting following error:
>>>>
>>>> ninja -j1 -C out.gn/x64.debug
>>>> ninja: Entering directory `out.gn/x64.debug'
>>>> [1/287] LINK v8_simple_json_fuzzer.exe
>>>> FAILED: v8_simple_json_fuzzer.exe
>>>> L:/depot_tools/python276_bin/python.exe gyp-win-tool link-wrapper 
>>>> environment.x64 False link.exe /nologo /OUT:v8_simple_
>>>> json_fuzzer.exe /PDB:v8_simple_json_fuzzer.exe.pdb 
>>>> @v8_simple_json_fuzzer.exe.rsp
>>>> LINK : warning LNK4044: unrecognized option '/fastfail'; ignored
>>>> LINK : error LNK2001: unresolved external symbol mainCRTStartup
>>>> v8_simple_json_fuzzer.exe : fatal error LNK1120: 1 unresolved externals
>>>>
>>>> what I am doing wrong? please advice.
>>>>
>>>> 2016-11-16 0:01 GMT+02:00 Ivan Pizhenko <[email protected] 
>>>> <javascript:>>:
>>>>
>>>>> Thaks, I will try this workaround, but also please tell me, what 
>>>>> exactly do you mean by current development branch? Which version of V8 
>>>>> does 
>>>>> it corresponds? 5.5?  5.6?
>>>>>
>>>>> 2016-11-10 20:33 GMT+02:00 Jochen Eisinger <[email protected] 
>>>>> <javascript:>>:
>>>>>
>>>>>> on 5.3, it's not yet possible to build the libplatform as a shared 
>>>>>> library (dll), sorry. This is fixed in the current development branch.
>>>>>>
>>>>>> also, by default we don't actually create static libraries, but gn 
>>>>>> just keeps track of the object files you need. You can change that by 
>>>>>> manually replacing source_set with static_library in the v8_source_set 
>>>>>> template in gni/v8.gni
>>>>>>
>>>>>> hth
>>>>>> -jochen
>>>>>>
>>>>>> On Thu, Nov 10, 2016 at 3:37 PM Ivan Pizhenko <[email protected] 
>>>>>> <javascript:>> wrote:
>>>>>>
>>>>>>> So I would like to hear comments on this from some V8 developer or 
>>>>>>> whoever solved the issue w/o Nuget package.
>>>>>>>
>>>>>>> 2016-11-10 16:05 GMT+02:00 Ivan Pizhenko <[email protected] 
>>>>>>> <javascript:>>:
>>>>>>>
>>>>>>>> Thank you for advise, George, but what you suggest is not an option 
>>>>>>>> in the my case, I need to have built from sources exactly this stable 
>>>>>>>> version 5.3.332.45. There is no Nuget package fir exactly this 
>>>>>>>> version, and 
>>>>>>>> there are also other circumstances those prevent me using  Nuget 
>>>>>>>> package. 
>>>>>>>> So I am looking for exactly an explanation on how to solve this 
>>>>>>>> manually.
>>>>>>>>
>>>>>>>> 2016-11-09 19:36 GMT+02:00 George Marques <[email protected] 
>>>>>>>> <javascript:>>:
>>>>>>>>
>>>>>>>>> I also had troubles with the build system. I found it's much 
>>>>>>>>> easier to just use this Nuget package: 
>>>>>>>>> https://github.com/pmed/v8-nuget.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Wednesday, November 9, 2016 at 5:42:19 AM UTC-2, Ivan P. wrote:
>>>>>>>>>>
>>>>>>>>>> Hello, I am porting my app from V8 3.19 to V8 5.3.332.45.
>>>>>>>>>> I have built new V8 version as DLL using Visual Studio 2013, 
>>>>>>>>>> updated code of my app to use updated APIs  and now trying to 
>>>>>>>>>> perform full 
>>>>>>>>>> build of my app.
>>>>>>>>>> My app doesn't use GN to build it, it is normal Visual Studio 
>>>>>>>>>> 2013 project. I have specified v8.dll.lib as additional linker input.
>>>>>>>>>>
>>>>>>>>>> I get following linker error:
>>>>>>>>>> 1>v8init.obj : error LNK2019: unresolved external symbol "class 
>>>>>>>>>> v8::Platform * __cdecl v8::platform::CreateDefaultPlatform(int)" 
>>>>>>>>>> (?CreateDefaultPlatform@platform@v8@@YAPEAVPlatform@2@H@Z) 
>>>>>>>>>> referenced in 
>>>>>>>>>> function .... "
>>>>>>>>>>
>>>>>>>>>> I suppose v8::platform::CreateDefaultPlatform() must be present 
>>>>>>>>>> in libplatform, but because the error happens, I can make conclusion 
>>>>>>>>>> that 
>>>>>>>>>> libplatform it is not included into v8.dll.lib.
>>>>>>>>>> I have examined V8 build outputs and couldn't find libplatform as 
>>>>>>>>>> separate static lib or DLL: here is list of libs generated during 
>>>>>>>>>> the 
>>>>>>>>>> build, here is what I have:
>>>>>>>>>>
>>>>>>>>>> icui18n.dll
>>>>>>>>>> icuuc.dll
>>>>>>>>>> msvcp120.dll
>>>>>>>>>> msvcp120d.dll
>>>>>>>>>> msvcr120.dll
>>>>>>>>>> msvcr120d.dll
>>>>>>>>>> pgort120.dll
>>>>>>>>>> v8.dll
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> cctest.lib
>>>>>>>>>> generate-bytecode-expectations.lib
>>>>>>>>>> icui18n.dll.lib
>>>>>>>>>> icuuc.dll.lib
>>>>>>>>>> mksnapshot.lib
>>>>>>>>>> unittests.lib
>>>>>>>>>> v8.dll.lib
>>>>>>>>>> v8_parser_shell.lib
>>>>>>>>>> v8_simple_json_fuzzer.lib
>>>>>>>>>> v8_simple_parser_fuzzer.lib
>>>>>>>>>> v8_simple_regexp_fuzzer.lib
>>>>>>>>>> v8_simple_wasm_asmjs_fuzzer.lib
>>>>>>>>>> v8_simple_wasm_fuzzer.lib
>>>>>>>>>>
>>>>>>>>>> Please advise - either how to tune build to have libplatform 
>>>>>>>>>> generated as separate DLL or included to v8.dll ?
>>>>>>>>>> Or is it safe to make manually libplatform from obj files and 
>>>>>>>>>> link it, taking into account v8 is DLL?
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> -- 
>>>>>>>>> -- 
>>>>>>>>> v8-users mailing list
>>>>>>>>> [email protected] <javascript:>
>>>>>>>>> http://groups.google.com/group/v8-users
>>>>>>>>> --- 
>>>>>>>>> You received this message because you are subscribed to a topic in 
>>>>>>>>> the Google Groups "v8-users" group.
>>>>>>>>> To unsubscribe from this topic, visit 
>>>>>>>>> https://groups.google.com/d/topic/v8-users/Y05xPj956Ys/unsubscribe
>>>>>>>>> .
>>>>>>>>> To unsubscribe from this group and all its topics, send an email 
>>>>>>>>> to [email protected] <javascript:>.
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> -- 
>>>>>>> -- 
>>>>>>> v8-users mailing list
>>>>>>> [email protected] <javascript:>
>>>>>>> http://groups.google.com/group/v8-users
>>>>>>> --- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "v8-users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected] <javascript:>.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>> -- 
>>>>>> -- 
>>>>>> v8-users mailing list
>>>>>> [email protected] <javascript:>
>>>>>> http://groups.google.com/group/v8-users
>>>>>> --- 
>>>>>> You received this message because you are subscribed to a topic in 
>>>>>> the Google Groups "v8-users" group.
>>>>>> To unsubscribe from this topic, visit 
>>>>>> https://groups.google.com/d/topic/v8-users/Y05xPj956Ys/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>>> [email protected] <javascript:>.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to