1.Build with “use_custom_libcxx=false” args for gn will get error: ld.lld: error: undefined symbol: _Unwind_Backtrace
FAILED: libjingle_peerconnection_so.so libjingle_peerconnection_so.so.TOC lib.unstripped/libjingle_peerconnection_so.so
python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Release+Asserts/bin/llvm-readelf" --nm="../../third_party/llvm-build/Release+Asserts/bin/llvm-nm" --strip=../../third_party/llvm-build/Release+Asserts/bin/llvm-strip --sofile="./lib.unstripped/libjingle_peerconnection_so.so" --tocfile="./libjingle_peerconnection_so.so.TOC" --output="./libjingle_peerconnection_so.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libjingle_peerconnection_so.so" -lEGL -Wl,--build-id -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=4096 -Wl,--color-diagnostics -Wl,--no-rosegment -Wl,--no-call-graph-profile-sort -Wl,--exclude-libs=libvpx_assembly_arm.a --unwindlib=none --target=aarch64-linux-android21 -Wl,-mllvm,-enable-machine-outliner=never -no-canonical-prefixes -Werror -Wl,--gdb-index --sysroot=../../third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--warn-shared-textrel -Wl,-z,defs -Wl,--as-needed -Wl,--version-script=../../build/android/android_only_jni_exports.lst -Wl,--dynamic-linker,/system/bin/linker64 -o "./lib.unstripped/libjingle_peerconnection_so.so" @"./libjingle_peerconnection_so.so.rsp"
ld.lld: error: undefined symbol: _Unwind_Backtrace
>>> referenced by stacktrace.cc:227 (../../sdk/android/native_api/stacktrace/stacktrace.cc:227)
问题解决:
https://bugs.chromium.org/p/webrtc/issues/detail?id=13535
2、absl 相关如果在链接时报类似错误:
Undefined symbols for architecture arm64:
"webrtc::VideoFrame::Builder::set_update_rect(std::__1::optional const&)", referenced from:
RtcVideoCapturer::OnFrame(webrtc::VideoFrame const&) in RtcVideoCapturer.o
但是 libwebrtc 用的是 absl::optional,在应用程序中使用的是 std::optional,需保持一致。
将 webrtc-checkout/src/third_party/abseil-cpp/absl/base/options.h 中 ABSL_OPTION_USE_STD_ANY 、ABSL_OPTION_USE_STD_OPTIONAL ABSL_OPTION_USE_STD_STRING_VIEW 和 ABSL_OPTION_USE_STD_VARIANT 四个宏的值改为从 2 改为 0 再重新编译 webrtc
问题解决:
https://blog.tubumu.com/2022/03/11/mediasoup-02/
mediasoup 适配新webrtc
webrtc_88 % cp ./rtc_base/constructor_magic.h rtc_base/atomic_ops.h /Users/Downloads/mediasoup-client-android/mediasoup-client/deps/webrtc/src/rtc_base/
webrtc_88 % cp ./sdk/android/src/jni/class_reference_holder.h /Users/Downloads/mediasoup-client-android/mediasoup-client/deps/webrtc/src/sdk/android/src/jni/
https://juejin.cn/post/7221454955265556540
编译libwebrtc.a 和 libwebrtc.jar
默认不会编译 webrtc 模块,我们需要在/tools_webrtc/android/build_aar.py 文件中加入 ‘:webrtc’
TARGETS = [
':webrtc',
'sdk/android:libwebrtc',
'sdk/android:libjingle_peerconnection_so',
]
./tools_webrtc/android/build_aar.py --extra-gn-args 'is_debug=false is_component_build=false is_clang=true treat_warnings_as_errors=false' --build-dir ./out/release-build/