编译iOS WebRTC 静态库,链接时候报错
Undefined symbols for architecture arm64:
"webrtc::RtpExtension::RtpExtension(std::__1::basic_string_view<char, std::__1::char_traits<char> >, int)", referenced from:
zp_webrtc::ZPAVErrorType rtc::FunctionView<zp_webrtc::ZPAVErrorType ()>::CallVoidPtr<webrtc::NebulaPushlishChannelHelperImpl::startLocalAudioSend(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int const&)::$_16>(rtc::FunctionView<zp_webrtc::ZPAVErrorType ()>::VoidUnion) in NebulaChannelHelperImpl.o
"typeinfo for webrtc::SrtpTransport", referenced from:
typeinfo for zp_webrtc::ZPSrtpInternalTransport in zpTransport.o
"typeinfo for rtc::MessageHandler", referenced from:
typeinfo for webrtc::MethodCall<webrtc::NebulaCallConfig, bool> in NebulaCallConfig-8879677226ab8c9a89635da475c6c00e.o
"webrtc::SrtpTransport::OnNetworkRouteChanged(std::__1::optional<rtc::NetworkRoute>)", referenced from:
vtable for zp_webrtc::ZPSrtpInternalTransport in zpTransport.o
"typeinfo for rtc::LogSink", referenced from:
typeinfo for zp_webrtc::NebulaWebrtcLog in NebulaWebrtcLog.o
"typeinfo for rtc::PacketTransportInternal", referenced from:
typeinfo for zp_webrtc::ZPUdpOperator in zpUdpOperator.o
"typeinfo for webrtc::FieldTrialParameterInterface", referenced from:
typeinfo for webrtc::FieldTrialParameter<webrtc::DataRate> in NebulaMediaChannelPlayControl.o
"typeinfo for rtc::AsyncClosure", referenced from:
typeinfo for rtc::FireAndForgetAsyncClosure<rtc::MethodFunctor<zp_webrtc::NebulaMediaChannelPlayControl, void (zp_webrtc::NebulaMediaChannelPlayControl::*)(), void> > in NebulaMediaChannelPlayControl.o
typeinfo for rtc::FireAndForgetAsyncClosure<rtc::MethodFunctor<zp_webrtc::ZPUdpOperator, void (zp_webrtc::ZPUdpOperator::*)(), void> > in zpUdpOperator.o
typeinfo for rtc::FireAndForgetAsyncClosure<rtc::MethodFunctor<webrtc::NebulaPushlishChannelHelperImpl, void (webrtc::NebulaPushlishChannelHelperImpl::*)(), void> > in NebulaChannelHelperImpl.o
typeinfo for rtc::FireAndForgetAsyncClosure<webrtc::NebulaPushlishChannelHelperImpl::OnRtcpPacketReceived_n(rtc::CopyOnWriteBuffer*, long long)::$_20> in NebulaChannelHelperImpl.o
"std::__1::optional<webrtc::DataRate> webrtc::ParseTypedParameter<webrtc::DataRate>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
webrtc::FieldTrialParameter<webrtc::DataRate>::Parse(std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in NebulaMediaChannelPlayControl.o
"webrtc::FieldTrialBasedConfig::Lookup(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const", referenced from:
zp_webrtc::NebulaMediaChannelPlayControl::CreateCall(webrtc::RtcEventLog*) in NebulaMediaChannelPlayControl.o
webrtc::NebulaCallConfig::CreateCall(webrtc::RtcEventLog*) in NebulaCallConfig-8879677226ab8c9a89635da475c6c00e.o
webrtc::NebulaCallConfig::CreateCall(webrtc::RtcEventLog*) in NebulaCallConfig-aa473c961879510618c7fe80a29a2a2c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
开始以为就是符号找不到,怎么改都无果。而且报的都是类型未定义,不是具体方法未定义,都发生在类继承的时候。后发现是webrtc编译关了rtti
,上层编译链接开了 rtti
,上层关了就可以了。
xcode 关闭 rtti
,找到 build settings
搜索 runtime types
,设置成 No
参考:
- stackoverflow的回答: https://stackoverflow.com/questions/1693634/undefined-symbols-vtable-for-and-typeinfo-for:
There is another reason you can get this error, and just want to document it here. I was linking with a static library which did not have RTTI. So Using the C++ flag -fno-rtti fixed for me. If you do not need RTTI, you can using this flag as well. Hope this helps.
还有一种
webrtc::ParseTypedParameter<webrtc::DataRate>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
webrtc::FieldTrialParameter<webrtc::DataRate>::Parse(std::__1::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) in NebulaMediaChannelPlayControl.o
"webrtc::FieldTrialBasedConfig::Lookup(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const", referenced from:
是由于c++17中增加了 string_view类型,webrtc中用的是谷歌自己的 absl库中的string_view,上层在链接的时候按stl去找的,所以链接不到,把上层c++17的编译选项改为c++14即可。xcode在这里:
image.png
搞了两天,涨知识了👏🏻 🍻
网友评论