Xamarin.iOS本机链接错误MTOUCH MT5210未定义符号std :: string [英] Xamarin.iOS native linking error MTOUCH MT5210 undefined symbol std::string

查看:185
本文介绍了Xamarin.iOS本机链接错误MTOUCH MT5210未定义符号std :: string的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Xamarion.iOS绑定项目具有指向所有必需的本机视频SDK库和本机OS框架的链接。我已经使用Frameworks属性设置了所需的框架。其他设置包括SmartLink = true,ForceLoad = true,IsCxx = true,LinkerFlags =-lc ++。可以将其内置到C#DLL中。在iOS项目中,DLL被引用和使用。但是,存在本机链接错误。

My Xamarion.iOS binding project has the links to all the required native video SDK libraries and native OS frameworks. I have set the required frameworks using Frameworks attribute. Other settings include SmartLink=true, ForceLoad=true, IsCxx=true, LinkerFlags="-lc++". It can be built into a C# DLL. In iOS project, the DLL is referenced and used. However there are native linking errors.

MTOUCH:MT5210错误:本机链接失败,未定义符号:std :: string :: _ Rep :: _ M_destroy(std :: allocator const& ;)。请验证是否已引用所有必需的框架,并且正确链接了本机库。

MTOUCH: Error MT5210: Native linking failed, undefined symbol: std::string::_Rep::_M_destroy(std::allocator const&). Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.

构建日志中的详细信息:
体系结构arm64的未定义符号:
std :: string :: _ Rep :: _ M_destroy(std :: allocator const&),引用自:libHCCore.a(HPR_Utils.o)
中的
HPR_UTF82A(char const *) libHCCore.a(HPR_Utils.o)中的HPR_A2UTF8(char const *)
std :: string :: _ Rep :: _ S_empty_rep_storage,引用自:
libHCCore.a(中的HPR_UTF82A(char const *)) HPHC_Utils.o)
libHCCore.a(HPR_Utils.o)
中的HPR_A2UTF8(char const *)
std :: string :: assign(char const *,unsigned long),引用自:$ b libHCCore.a(HPR_Utils.o)中的$ b HPR_UTF82A(char const *)$ libHCCore.a(HPR_Utils.o)中的
HPR_A2UTF8(char const *)
std :: basic_string,std :: allocator > :: basic_string(char const *,std :: allocator const&),引用自:
HPR_A2UTF8(char co libHCCore.a(HPR_Utils.o)中的nst *)
std :: basic_string,std :: allocator> :: basic_string(std :: string const&),引用自:
HPR_A2UTF8(char libHCCore.a(HPR_Utils.o)中的const *)
ld:找不到体系结构arm64
的符号clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

The details in build log: Undefined symbols for architecture arm64: "std::string::_Rep::_M_destroy(std::allocator 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, std::allocator >::basic_string(char const*, std::allocator const&)", referenced from: HPR_A2UTF8(char const*) in libHCCore.a(HPR_Utils.o) "std::basic_string, std::allocator >::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:警告MT5215:引用系统可能需要附加-framework =对本机链接程序(MT5215)的XXX或-lXXX指令

MTOUCH: Warning MT5215: References to 'System' might require additional -framework=XXX or -lXXX instructions to the native linker (MT5215)

错误MT5201:本机链接失败。请查看生成日志和提供给gcc的用户标志:-ObjC(MT5201)

Error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -ObjC (MT5201)

MTOUCH:错误MT5202:本机链接失败。请查看构建日志。 (MT5202)

MTOUCH: Error MT5202: Native linking failed. Please review the build log. (MT5202)

clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

clang: Error: linker command failed with exit code 1 (use -v to see invocation)

请阐明。

在Xcode中没有这种本机链接错误。构建设置:

No such native linking error in Xcode. The build settings:

推荐答案

托管链接和本机链接可能会删除代码。全部链接可能会删除更多代码。因此需要解决问题,而不是使用全部链接使问题消失。使用全部链接时,需要使用Preserve属性保存代码。

Managed linking and native linking may remove code. Link All may remove more code. So need to solve the problem instead of making the issues disappear using Link All. When using Link All, need to use Preserve attribute to preserve code.

我添加了所有本机引用,请正确设置链接选项。另外,我将链接器标志设置为正确包含所有必需的OS平台框架。在添加对本机动态框架的引用后,错误消失了。然后,我得到了重复的符号,而不是得到未定义的符号。我必须删除对本机库的引用。

I added all native references, set the linking options correctly. Also I set the linker flags to include all the required OS platform frameworks correctly. After adding reference to a native dynamic framework, the error disappeared. Then instead of getting undefined symbols, I got duplicate symbols. I had to remove a reference to a native library.

尽管iOS项目是在引用动态框架后链接并构建的,但存在运行时问题。我们的SDK提供者确认我们一定不能使用他们的动态框架。动态框架是为其他客户提供的,用于Xcode中不同的目标SimpleDemo_Dy。它们是旧版本的SDK。我们应该只使用静态库。

Although the iOS project is linked and built after referencing dynamic frameworks, there is a runtime issue. Our SDK provider confirmed that we must not use their dynamic frameworks. The dynamic frameworks are provided for other customers for a different target SimpleDemo_Dy in Xcode. They are older versions SDK. We should just use the static libraries.

我已经重新检查了Xcode构建日志。 Xcode中没有动态框架用于目标SimpleDemo。问题是为什么Xcode项目在不使用任何动态框架的情况下进行构建,而Visual Studio for Mac的构建却由于本机链接错误而失败?

I have re-examined the Xcode build log. No dynamic frameworks are used for target SimpleDemo in Xcode. The question is why Xcode project builds without using any dynamic frameworks, but Visual Studio for Mac build fails with a native linking error?

我创建了一个示例iOS应用程序,仅使用静态库。它生成并运行正常。我已经与您分享了示例iOS应用。链接为 https://drive.google.com/file/d / 10QXkaZE7lURN6IF96NIrTGY2lmn88ctF / view?usp = sharing

I’ve created a sample iOS app which only uses static libraries. It builds and runs OK. I've shared the sample iOS app with you. The link is https://drive.google.com/file/d/10QXkaZE7lURN6IF96NIrTGY2lmn88ctF/view?usp=sharing.

在相同的绑定项目设置下,我们无法在我们的产品应用程序中实现相同的功能。我什至尝试从示例应用程序交换绑定项目。它没有帮助。我还比较了项目选项UI和WinMerge中的iOS项目设置。我仍然找不到问题所在。我已经尝试过多次清洁和重建。我试图签出到一个新的工作区。它仍然有未定义的符号错误。

I haven’t been able to achieve the same in our product app with identical binding project settings. I even tried to swap the binding project from the sample app. It didn't help. Also I compared the iOS project settings from project options UI and WinMerge. I still couldn't find what's wrong. I have tried clean and rebuild many times. I have tried to check out to a fresh workspace. It still has undefined symbol error.

我认为问题是本地库之一libHCCore.a使用libstdc ++编译,导致错误的未定义符号std :: string,而其余都是libc ++。

I think the issue is one of the native libraries libHCCore.a is compiled with libstdc++ which caused the error undefined symbol std::string while the rest are libc++.

向本地引用添加链接器标志-lstdc ++并没有帮助。如何在iOS项目中使用其他Mtouch参数或在绑定项目中使用其他btouch参数来解决此问题?

Adding Linker Flags -lstdc++ to the native reference didn't help. How to used additional Mtouch arguments in iOS project or additional btouch arguments in binding project to resolve the issue?

这篇关于Xamarin.iOS本机链接错误MTOUCH MT5210未定义符号std :: string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆