0

I met some issues when I wanted to build the peerconnection example with linking Webrtc as a static library.

My build environment and the target are both ubuntu 18.04, and I used the Github repo https://github.com/vsimon/webrtcbuilds to build the Webrtc as a static library.

Then there were many link errors about absl libray, after some investigations, I added some build args to eliminate the majority of them as below:

is_debug=false
is_component_build=false
is_clang=false
rtc_include_tests=false
rtc_use_h264=true
rtc_enable_protobuf=false
use_rtti=true
use_custom_libcxx=false
treat_warnings_as_errors=false
use_ozone=true

But it still has several link errors that I can't tackle:

/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::DeadlineFromTimeout(absl::Duration) [clone .isra.8]':
mutex.cc:(.text._ZN4abslL19DeadlineFromTimeoutENS_8DurationE.isra.8+0x24): undefined reference to `absl::TimeFromTimeval(timeval)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::AwaitWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex17AwaitWithDeadlineERKNS_9ConditionENS_4TimeE+0xa4): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::LockWhenWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex20LockWhenWithDeadlineERKNS_9ConditionENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::Mutex::ReaderLockWhenWithDeadline(absl::Condition const&, absl::Time)':
mutex.cc:(.text._ZN4absl5Mutex26ReaderLockWhenWithDeadlineERKNS_9ConditionENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(mutex.o): In function `absl::CondVar::WaitWithDeadline(absl::Mutex*, absl::Time)':
mutex.cc:(.text._ZN4absl7CondVar16WaitWithDeadlineEPNS_5MutexENS_4TimeE+0x27): undefined reference to `absl::ToUnixNanos(absl::Time)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(bind.o): In function `absl::str_format_internal::FormatUntyped(absl::str_format_internal::FormatRawSinkImpl, absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)':
bind.cc:(.text._ZN4absl19str_format_internal13FormatUntypedENS0_17FormatRawSinkImplENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x159): undefined reference to `absl::str_format_internal::kTags'
bind.cc:(.text._ZN4absl19str_format_internal13FormatUntypedENS0_17FormatRawSinkImplENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x457): undefined reference to `absl::str_format_internal::ConsumeUnboundConversion(char const*, char const*, absl::str_format_internal::UnboundConversion*, int*)'
/home/alexander/works/lab/webrtc-native/test_project/peerconnection/lib/Release/libwebrtc_full.a(bind.o): In function `absl::str_format_internal::Summarize[abi:cxx11](absl::str_format_internal::UntypedFormatSpecImpl, absl::Span<absl::str_format_internal::FormatArgImpl const>)':
bind.cc:(.text._ZN4absl19str_format_internal9SummarizeB5cxx11ENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0x18b): undefined reference to `absl::str_format_internal::kTags'
bind.cc:(.text._ZN4absl19str_format_internal9SummarizeB5cxx11ENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE+0xa12): undefined reference to `absl::str_format_internal::ConsumeUnboundConversion(char const*, char const*, absl::str_format_internal::UnboundConversion*, int*)'

I hope anyone can give me some hints to fix them, thanks very much!

alexunder
  • 2,213
  • 2
  • 13
  • 18
  • How are you compiling the code? I also recently built webrtc for linux but trying to link it with other library threw me a lot of linker errors. Here is what I did: First looked at whether the libwebrtc.a has all the symbols using `nm` utility. Found out that all the symbols were there but then a peculiar thing was all errors were having `std::__cxx11::basic_string` and after some searching on this site I found out that issue might be ABI compatibility. Finally the issue was that webrtc is written in c++14 and though they say it's compatible with c++17 believe me it;s not. – Yug Singh Jul 24 '20 at 20:05
  • So I used `cxx_std_14` and it fixed all the linker errors. All of your linker errors seems to be coming from absl. Ensure that the [abseil](https://github.com/abseil/abseil-cpp) is there in the path where linker is looking for. – Yug Singh Jul 24 '20 at 20:11
  • Also use a demangler utility to understand the complete linker errors. Look at [this](https://stackoverflow.com/a/10466773/6407858). For example if I demangle the `_ZN4absl19str_format_internal13FormatUntypedENS0_17FormatRawSinkImplENS0_21UntypedFormatSpecImplENS_4SpanIKNS0_13FormatArgImplEEE` from one of the linker errors it actually is `absl::str_format_internal::FormatUntyped(absl::str_format_internal::FormatRawSinkImpl, absl::str_format_internal::UntypedFormatSpecImpl, absl::Span)` – Yug Singh Jul 24 '20 at 20:11

0 Answers0