【发布时间】:2020-05-20 01:47:18
【问题描述】:
我的 Xamarion.iOS 绑定项目具有指向所有必需的本机视频 SDK 库和本机 OS 框架的链接。我已经使用 Frameworks 属性设置了所需的框架。其他设置包括 SmartLink=true、ForceLoad=true、IsCxx=true、LinkerFlags="-lc++"。它可以内置到 C# DLL 中。在 iOS 项目中,DLL 被引用和使用。但是存在本地链接错误。
MTOUCH: Error MT5210: Native linking failed, undefined symbol: std::string::_Rep::_M_destroy(std::allocator<char> const&). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
构建日志中的详细信息:
> Undefined symbols for architecture arm64:
> "std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
> HPR_UTF82A(char const*) in libHCCore.a(HPR_Utils.o)
> HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o)
> "std::string::_Rep::_S_empty_rep_storage", referenced from:
> HPR_UTF82A(char const*) in libHCCore.a(HPR_Utils.o)
> HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o)
> "std::string::assign(char const*, unsigned long)", referenced from:
> HPR_UTF82A(char const*) in libHCCore.a(HPR_Utils.o)
> HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o)
> "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char>
> const&)", referenced from:
> HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o)
> "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)", referenced
> from:
> HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o)
> ld: symbol(s) not found for architecture arm64
> clang : error : linker command failed with exit code 1 (use -v to see invocation)
换行错误:
MTOUCH: Warning MT5215: References to 'System' might require additional -framework=XXX or -lXXX instructions to the native linker (MT5215)
Error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -ObjC (MT5201)
MTOUCH: Error MT5202: Native linking failed. Please review the build log. (MT5202)
clang: Error: linker command failed with exit code 1 (use -v to see invocation)
请解释一下。谢谢。
Xcode 中没有这样的本机链接错误。构建设置:
【问题讨论】:
-
代码中没有本机链接错误。 Xcode 中的设置(来自构建日志):
-
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c++ -target armv7-apple-ios8.0 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -stdlib=libc++
-
Xcode: -Xlinker -no_deduplicate -stdlib=libc++ -fobjc-link-runtime -liconv -lssl -lAudioEngine_64 -lplayctrl -lSystemTransform -framework QuartzCore -framework CoreVideo -framework CoreMedia -framework GLKit -framework VideoToolbox -框架 AudioToolbox -framework Foundation -framework UIKit -lHCNetSDK -lHCCore -lcrypto -framework CoreGraphics -framework OpenGLES -framework CoreGraphics -framework OpenAL
-
我已将 Xcode 升级到 11.5,并将 Visual Studio for Mac 升级到 8.6 build 4520。在 iOS 构建项目设置中将链接器行为设置为 Link All。本机链接错误消失了,但是链接全部引起了一个新问题。我们不能再使用 DependencyService。 iOS 应用将无法加载,因为 DependencyService 甚至无法解析带有 Null 引用的 IFileHelper 的第一个平台实现。
-
这看起来像一个 Xamarin 错误,请参阅 stackoverflow.com/questions/61757404/…。我已经尝试了 Additional mtouch arguments --linkskip tecommobile 以及docs.microsoft.com/en-us/xamarin/ios/deploy-test/… 中的其他一些方法。我无法解决问题。
标签: dependency-injection xamarin.ios linker native static-linking