Hi,

I'm not sure if this will help you a month after your question, but I 
happened to be looking at some similar problems recently so I'll share what 
I found. In short, is_clang = false is incompatible with is_component_build 
= true. As you found, the linker encounters numerous errors related to 
dllexport and dllimport functions. I believe that this is because V8 
depends on the Clang-specific compilation flag /Zc:dllexportInlines- which 
means "if a function is both inline and declared as dllexport or dllimport, 
then ignore the dllexport or dllimport part". However, if a static library 
would work for you, it's an option. I just tested a small sample app in 
Visual Studio using a recent V8 master version, with the following steps:

1. Set up args.gn like so (I believe is_debug = true or different 
target_cpu would work also):

is_clang = false
is_component_build = false
is_debug = false
target_cpu = "x64"
use_goma = false
v8_monolithic = true
v8_use_external_startup_data = false

2. Run "autoninja v8_monolith" in the out.gn\x64.debug directory to create 
obj\v8_monolith.lib.

3. In the Visual Studio project that needs to embed V8, set some settings:

Add to Linker->Input->Additional Dependencies: 
winmm.lib;dbghelp.lib;v8_monolith.lib
Add to Linker->General->Additional Library Directories: 
%USERPROFILE%\oss\v8\out.gn\x64.debug\obj
Change C/C++->Code Generation->Runtime Library to "Multi-threaded (/MT)"
Add to C/C++->General->Additional Include Directories: 
%USERPROFILE%\oss\v8\include

On Thursday, July 18, 2019 at 6:56:57 AM UTC-7, deadmorous wrote:
>
> Hi,
>
> I'm trying to embed V8 on Windows into a program built with Visual Studio 
> 2017, which I already done before (last time it was ok with version 7.1.9).
> Now I'm upgrading to V8 version 7.7.99, but my builds fail with linker 
> errors.
> I build V8, according to the build instructions, as follows:
>
> > cd %USERPROFILE%\oss
> > set PATH=%USERPROFILE%\oss\depot_tools;%PATH%
> > set DEPOT_TOOLS_WIN_TOOLCHAIN=0
> > set GYP_MSVS_VERSION=2017
> > gclient
> > mkdir v8
> > cd v8
> > fetch v8
> > cd v8
> > git checkout 7.7.99
> > gclient sync
> > gn gen out.gn/x64.debug --args="v8_use_external_startup_data=false 
> is_component_build=true use_custom_libcxx=false is_debug=true"
> > ninja -C out.gn/x64.debug
>
>
> The problem is that V8 is built with clang, while I'm using cl. There are 
> linker errors like this:
>
>
> om_v8_runproc.cpp.obj:-1: error: LNK2019: unresolved external symbol 
> "__declspec(dllimport) 
> public: __cdecl v8::EscapableHandleScope::~EscapableHandleScope(void)" (
> __imp_??1EscapableHandleScope@v8@@QEAA@XZ) referenced in function "void 
> __cdecl ctm::lang::om_v8_runproc::`anonymous namespace'::jn_runproc(class 
> v8::FunctionCallbackInfo<class v8::Value> const &)" (?jn_runproc@?
> A0xb330fd70@om_v8_runproc@lang@ctm@@YAXAEBV?
> $FunctionCallbackInfo@VValue@v8@@@v8@@@Z)
>
>
> There are many inline functions that the linker for some reason expects to 
> be exported from v8.dll
>
>
> As I have found, for example, cl expects default constructors and 
> destructors to be exported, but clang does not export those (see 
> https://stackoverflow.com/questions/53283030/clang-fails-to-generate-defaulted-move-constructor-upon-template-instantiation
> ).
>
>
> I tried building V8 with additional GN argument is_clang=false, but in 
> that case there are a lot of link errors during V8 build, so the build 
> fails.
>
>
> Finally, I tried building the old version, 7.1.9, but the build that 
> worked fine before now fails (the reason is that the redistributable files 
> in Windows 10 SDK are now in a different folder).
>
>
> So my questions are:
>
>    1. Is it possible to build V8 7.7.99 using Visual Studio and the cl 
>    compiler?
>    2. If not, is it possible to use the clang build in a program built 
>    with cl? How to do that?
>    3. If not, maybe the above options are available for an ealier version 
>    of V8?
>
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/9c754a29-8590-45cb-9028-bab449bd4c4e%40googlegroups.com.

Reply via email to