編譯iOS WebRTC 靜態(tài)庫醒颖,鏈接時候報錯
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)
開始以為就是符號找不到雇锡,怎么改都無果。而且報的都是類型未定義贬蛙,不是具體方法未定義雨女,都發(fā)生在類繼承的時候。后發(fā)現(xiàn)是webrtc編譯關了rtti
阳准,上層編譯鏈接開了 rtti
氛堕,上層關了就可以了。
xcode 關閉 rtti
野蝇,找到 build settings
搜索 runtime types
岔擂,設置成 No
image.png
參考:
- 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
搞了兩天痛倚,漲知識了???? ??