Build only Chromium Network Stack compatible with MSVC

153 views
Skip to first unread message

amankum...@gmail.com

unread,
Jun 25, 2020, 4:54:58 AM6/25/20
to net-dev
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!

David Benjamin

unread,
Jun 25, 2020, 9:48:01 AM6/25/20
to amankum...@gmail.com, net-dev

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/a8532b52-2a56-4e09-93d0-5ac5e161b317o%40chromium.org.

amankum...@gmail.com

unread,
Jun 26, 2020, 12:41:00 AM6/26/20
to net-dev, amankum...@gmail.com
Yes, I learned it the hard way. The chromium network stack is already built by me as chrome_net.dll.
My question is how could I consume the clang-cl compiled binary (net_with_v8/ chrome_net) in my project which uses MSVC toolchain.
To unsubscribe from this group and stop receiving emails from it, send an email to net...@chromium.org.

amankum...@gmail.com

unread,
Jun 29, 2020, 7:26:08 AM6/29/20
to net-dev, amankum...@gmail.com
I found that cronet (//net C API wrapper for mobile devices) has "native" build support for x86/x64 architecture. Can this be used on windows application (VS with msvc toolchain) as the exported APIs are in C?
Does chromium developers support bug fixes related to cronet native build for Windows?

if anybody could help, that'll be nice.

Ryan Sleevi

unread,
Jun 29, 2020, 11:16:04 AM6/29/20
to amankum...@gmail.com, net-dev
No, MSVC is not a supported toolchain in Chromium.

To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/f278262d-b154-49d4-9593-006dd85981aeo%40chromium.org.

Caleb Raitto

unread,
Jun 29, 2020, 11:46:43 AM6/29/20
to rsl...@chromium.org, amankum...@gmail.com, net-dev, cronet-team
Cronet has a native C library, but we only support it on iOS -- we do build it on Linux for unit tests, and it *may* just work on Windows too. You might be able to build Cronet with clang and then consume it with msvc, especially since Cronet only exposes a C API -- however, this isn't a configuration we officially test and support.

-Caleb

Reply all
Reply to author
Forward
0 new messages