Hello Everyone!
I'm working on a project (in VS 2017 -MSVC toolchain) which is dependent on network stack of the Chromium browser. Getting few linking errors (Unresolved External Symbol) related with std::basic_string. Everything was fine till chromium v57.
Details:
1. for building binaries,
ninja -C . chrome_net /*net_with_v8*/
- (internally replaced net_with_v8 to chrome_net in various BUILD.gn files accordingly)
- GN args flag, is_component_build=true
Got binaries (chrome_net.dll, net.dll, base.dll, etc., and their respective *.lib files), added these in my project.
The project compiled successfully (of-course by commenting the __clang__ error) but giving few linking errors as below:
Error LNK2001 unresolved external symbol "public: bool __thiscall net::HttpRequestHeaders::GetHeader(class base::BasicStringPiece<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)const " (?GetHeader@HttpRequestHeaders@net@@QBE_NABV?$BasicStringPiece@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@base@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) Client <path_stripped>\chromium_transport.obj 1
Above symbol is exported in net.dll, I dumped symbol table using objdump and found std::__1::basic_string (inline namespacing):
$ objdump -t net.dll.lib | grep GetHeader
[ 3](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp_?GetHeader@HttpRequestHeaders@net@@QBE_NABV?$BasicStringPiece@V?$basic_string@DU?$char_traits@D@__1@std@@V?$allocator@D@23@@__1@std@@@base@@PAV?$basic_string@DU?$char_traits@D@__1@std@@V?$allocator@D@23@@__1@std@@@Z
[ 5](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 ?GetHeader@HttpRequestHeaders@net@@QBE_NABV?$BasicStringPiece@V?$basic_string@DU?$char_traits@D@__1@std@@V?$allocator@D@23@@__1@std@@@base@@PAV?$basic_string@DU?$char_traits@D@__1@std@@V?$allocator@D@23@@__1@std@@@Z
I tried to disable custom C++ library by using below flags (I'm aware of the fact that chromium switched to clang-cl only on windows from v64):
GN args flag, "use_custom_libcxx=false" and "use_custom_libcxx_for_host=false", but ninja gave lots of compile time error in chrome_net build.
Is there any way I can change the C++ library in chrome_net build given that I have to use MSVC only for my project? Or I need to do something else (C API wrapper or COM) which will be more efficient.
How should I consume chrome_net.dll (net_with_v8 renamed) in my MSVC toolchain based project?
Any help is appreciated. Thanks in advance!