I have built webrtc for linux and getting `libwebrtc.a` using
gn gen out/Default --args=is_debug=false rtc_use_h264=true target_cpu="x64" target_os="linux" clang_use_chrome_plugins=false use_ghash=false symbol_level=2 use_custom_libcxx=false is_component_ffmpeg=true ffmpeg_branding="Chrome" rtc_include_tests=false rtc_build_examples=true rtc_build_tools=false use_rtti=true rtc_enable_protobuf=false rtc_use_h264=true rtc_link_pipewire=true proprietary_codecs=true
and
ninja -C . webrtc \
peerconnection_client
but when I am trying to link the static webrtc with my c++ project I am getting following 4 linker errors:
1. test.cpp:(.text._ZN10H264BypassedEncoderC2ERKN7cricket10VideoCodecERNS_14DCVAgentClientE+0x191):
undefined reference to
`absl::EqualsIgnoreCase(std::basic_string_view<char,
std::char_traits<char> >, std::basic_string_view<char,
std::char_traits<char> >)'
2. CMakeFiles/webRTCserver.dir/src/audio/testEncoder.cpp.o:(.data.rel.ro._ZTVN10testEncoderE[_ZTVN10testEncoderE]+0xb8):
undefined reference to
`webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int,
std::optional<long>)'
3. testDecoderFactory.cpp/testEncoderFactory.cpp:(.text._ZN10testEncoderFactory20GetSupportedEncodersEv+0x20b): undefined reference to
`webrtc::SdpAudioFormat::SdpAudioFormat(std::basic_string_view<char,
std::char_traits<char> >, int, unsigned long,
std::map<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::less<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > >,
std::allocator<std::pair<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >&&)'
4. H264BypassedEncoder.cpp.o:(.data.rel.ro._ZTVN10H264BypassedEncoderE[_ZTVN10H264BypassedEncoderE]+0x20):
undefined reference to
`webrtc::VideoEncoder::SetFecControllerOverride(webrtc::FecControllerOverride*)'
When I look for symbols in libwebrtc.a like error 2 as shown below:
nm --demangle libwebrtc.a | grep -i webrtc::AudioEncoder::OnReceivedUplinkBandwidth
I get the following output:
0000000000000000 T webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
Now I am not sure why nm shows the output the way it does. But then using `ar -d libwebrtc.a <*.o>` I removed all the files which has
U webrtc::AudioEncoder::OnReceivedUplinkBandwidth(int, absl::optional<long>)
I am still getting the linker errors.
Same thing is with other undefined reference errors other than `webrtc::VideoEncoder::SetFecControllerOverride` which I am not sure which target will provide.
> Could someone tell me other way to debug errors 1,2 and 3 as the
> symbols are there in libwebrtc.a.
> Why is it that in 1st and 3rd undefined reference errors they refer to errors in .cpp files than in a .o file like in error 2
Also how to find ninja target for
> error 4 undefined reference?