Webrtc gn build for windows missed static libraries for windows application linkage

1,043 views
Skip to first unread message

George Zhou

unread,
Sep 15, 2016, 5:17:51 PM9/15/16
to discuss-webrtc
I have a windows visual studio demo application use webrtc. I used to build webrtc by gyp and link built static libraries with the demo application.

I switch to gn build recently since gyp build is depreciated. I found gn build create much less static libraries and I met a lot of link issue in my demo application. 

I set is_component_build = false and peerconnection_client.exe and peerconnection_server.exe works well.

Does any one have idea of this?

Here is the libraries I got
C:\mywork\webrtc\src\out\Debug64_gn\obj\build\config\sanitizers\options_sources.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\testing\gmock\gmock_main.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\testing\gmock\gmock.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\testing\gtest\gtest.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\base\rtc_base_approved.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\base\rtc_base.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\base\rtc_task_queue.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\modules\audio_coding\neteq_unittest_proto.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\modules\audio_processing\audioproc_debug_proto.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\modules\audio_processing\audioproc_unittest_proto.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\rtc_event_log_proto.lib
C:\mywork\webrtc\src\out\Debug64_gn\obj\webrtc\tools\chart_proto.lib

Here are some link error messages

Error LNK2019 unresolved external symbol "public: virtual class cricket::VideoCapturer * __cdecl cricket::WebRtcVideoDeviceCapturerFactory::Create(struct cricket::Device const &)" (?Create@WebRtcVideoDeviceCapturerFactory@cricket@@UEAAPEAVVideoCapturer@2@AEBUDevice@2@@Z) referenced in function "protected: class cricket::VideoCapturer * __cdecl Conductor::OpenVideoCaptureDevice(void)" (?OpenVideoCaptureDevice@Conductor@@IEAAPEAVVideoCapturer@cricket@@XZ) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2019 unresolved external symbol "public: static class webrtc::VideoCaptureModule::DeviceInfo * __cdecl webrtc::VideoCaptureFactory::CreateDeviceInfo(int)" (?CreateDeviceInfo@VideoCaptureFactory@webrtc@@SAPEAVDeviceInfo@VideoCaptureModule@2@H@Z) referenced in function "protected: class cricket::VideoCapturer * __cdecl Conductor::OpenVideoCaptureDevice(void)" (?OpenVideoCaptureDevice@Conductor@@IEAAPEAVVideoCapturer@cricket@@XZ) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2001 unresolved external symbol "public: static char const * const webrtc::MediaConstraintsInterface::kOfferToReceiveVideo" (?kOfferToReceiveVideo@MediaConstraintsInterface@webrtc@@2QBDB) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2001 unresolved external symbol "public: static char const * const webrtc::MediaConstraintsInterface::kOfferToReceiveAudio" (?kOfferToReceiveAudio@MediaConstraintsInterface@webrtc@@2QBDB) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2001 unresolved external symbol "public: static char const * const webrtc::MediaConstraintsInterface::kEnableDtlsSrtp" (?kEnableDtlsSrtp@MediaConstraintsInterface@webrtc@@2QBDB) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2019 unresolved external symbol "public: bool __cdecl webrtc::MediaConstraintsInterface::Constraints::FindFirst(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 " (?FindFirst@Constraints@MediaConstraintsInterface@webrtc@@QEBA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV45@@Z) referenced in function "public: void __cdecl webrtc::FakeConstraints::SetMandatory<bool>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool const &)" (??$SetMandatory@_N@FakeConstraints@webrtc@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEB_N@Z) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2019 unresolved external symbol "class webrtc::SessionDescriptionInterface * __cdecl webrtc::CreateSessionDescription(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 &,struct webrtc::SdpParseError *)" (?CreateSessionDescription@webrtc@@YAPEAVSessionDescriptionInterface@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0PEAUSdpParseError@1@@Z) referenced in function "public: bool __cdecl Conductor::ReceivedSdp(char const *)" (?ReceivedSdp@Conductor@@QEAA_NPEBD@Z) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2019 unresolved external symbol "class webrtc::IceCandidateInterface * __cdecl webrtc::CreateIceCandidate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct webrtc::SdpParseError *)" (?CreateIceCandidate@webrtc@@YAPEAVIceCandidateInterface@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H0PEAUSdpParseError@1@@Z) referenced in function "public: bool __cdecl Conductor::ReceivedIceCandidate(char const *)" (?ReceivedIceCandidate@Conductor@@QEAA_NPEBD@Z) SimplePeerConnection C:\mywork\unityplugin\VisualStudioDemo\SimplePeerConnection\SimplePeerConnection.obj 1
Error LNK2019 unresolved external symbol "class rtc::scoped_refptr<class webrtc::PeerConnectionFactoryInterface> __cdecl webrtc::CreatePeerConnectionFactory(class rtc::Thread *,class rtc::Thread *,class rtc::Thread *,class webrtc::AudioDeviceModule *,class cricket::WebRtcVideoEncoderFactory *,class cricket::WebRtcVideoDecoderFactory *,class webrtc::AudioSpatializationInterface *)" (?CreatePeerConnectionFactory@webrtc@@YA?AV?$scoped_refptr@VPeerConnectionFactoryInterface@webrtc@@@rtc@@PEAVThread@3@00PEAVAudioDeviceModule@1@PEAVWebRtcVideoEncoderFactory@cricket@@PEAVWebRtcVideoDecoderFactory@7@PEAVAudioSpatializationInterface@1@@Z) referenced in function "public: bool __cdecl Conductor::InitializePeerConnection(bool)" (?InitializePeerConnection@Conductor@@QEAA_N_N@Z)

radioman . lt

unread,
Sep 16, 2016, 3:39:06 PM9/16/16
to discuss-webrtc
..i have the same issue, it's supposed to generate webrtc_vp8.lib, but it doesnt ;/ wtf...

radioman . lt

unread,
Sep 16, 2016, 3:51:45 PM9/16/16
to discuss-webrtc
..weird thing, is that, right click on the project, then, 'Project Only'->'Link', and then it generates the f** lib ;/


On Friday, September 16, 2016 at 12:17:51 AM UTC+3, George Zhou wrote:

Bernhard Höckner

unread,
Sep 19, 2016, 2:36:17 AM9/19/16
to discuss-webrtc
might be a brute-force approach, but i replaced in the gn files source_set by static_library

a source_set targets seem to produce object files and do not get linked into .lib

maybe there is a better way?

George Zhou

unread,
Sep 19, 2016, 11:34:44 AM9/19/16
to discuss-webrtc
After I change webrtc.gni

237 template("rtc_source_set") {                                                     
238   static_library(target_name) {                                                  

instead of

237 template("rtc_source_set") {                                                     
238   source_set(target_name) { 

I hit following building issue though I got much more static libraries.

C:\mywork\webrtc\src>ninja -C out/D64_gn
ninja: Entering directory `out/D64_gn'
[7/317] LINK audio_classifier_test.exe audio_classifier_test.exe.pdb
FAILED: audio_classifier_test.exe audio_classifier_test.exe.pdb
C:/mywork/depot_tools/python276_bin/python.exe ../../build/toolchain/win/tool_wr
apper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./audio_classi
fier_test.exe /PDB:./audio_classifier_test.exe.pdb @./audio_classifier_test.exe.
rsp
LINK : fatal error LNK1104: cannot open file 'obj/webrtc/system_wrappers/system_
wrappers_default.lib'
[8/317] LINK unpack_aecdump.exe unpack_aecdump.exe.pdb
FAILED: unpack_aecdump.exe unpack_aecdump.exe.pdb
C:/mywork/depot_tools/python276_bin/python.exe ../../build/toolchain/win/tool_wr
apper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./unpack_aecdu
mp.exe /PDB:./unpack_aecdump.exe.pdb @./unpack_aecdump.exe.rsp
LINK : fatal error LNK1104: cannot open file 'obj/webrtc/system_wrappers/system_
wrappers_default.lib'
[9/317] LINK rtpcat.exe rtpcat.exe.pdb
FAILED: rtpcat.exe rtpcat.exe.pdb
C:/mywork/depot_tools/python276_bin/python.exe ../../build/toolchain/win/tool_wr
apper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./rtpcat.exe /
PDB:./rtpcat.exe.pdb @./rtpcat.exe.rsp
LINK : fatal error LNK1104: cannot open file 'obj/webrtc/system_wrappers/system_
wrappers_default.lib'
[20/317] CXX obj/webrtc/test/test_common/direct_transport.obj
ninja: build stopped: subcommand failed.

Bernhard Höckner

unread,
Sep 19, 2016, 11:42:22 AM9/19/16
to discuss-webrtc
i think i remove within src/webrtc/build.gn for the webrtc target the "tools" dependence
and within src/build.gn the dependency for webrtc/examples in the root group

as i said, a rather brute force approach

Henrik Kjellander

unread,
Sep 22, 2016, 9:12:11 AM9/22/16
to discuss-webrtc
We've pretty much confirmed that we misunderstood the use of source_set which was initially promoted as "use wherever you can" with GN and converted most of our targets to that. I filed https://bugs.chromium.org/p/webrtc/issues/detail?id=6410 to track fixing this and started working on a CL.

radioman . lt

unread,
Sep 22, 2016, 6:09:47 PM9/22/16
to discuss-webrtc
thanks Henrik!


On Friday, September 16, 2016 at 12:17:51 AM UTC+3, George Zhou wrote:
Reply all
Reply to author
Forward
0 new messages