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

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

问题描述

我的 Xamarion.iOS 绑定项目包含指向所有必需的本机视频 SDK 库和本机操作系统框架的链接.我已经使用 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: 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. 

构建日志中的详细信息:

The details in build log:

> 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 中没有这种本机链接错误.构建设置:

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

推荐答案

参见 https://github.com/xamarin/xamarin-macios/issues/8669.

我们了解到,我们的 iOS 应用程序的问题是由我们供应商 SDK 的 libstdc++ 和 libc++ 库混合引起的.他们的 libHCCore.a 是用 libstdc++ 编译的,而其余的都是用 libc++ 编译的.我在 Visual Studio for Mac 中尝试了其他链接选项,但失败了libstdc++ is deprecated"和Library –lstdc++ is not found".以下是 Microsoft Sebastien Pouliot 的建议:

We understand that the issue with our iOS app is caused by the mix of libstdc++ and libc++ libraries of our vendor's SDK. Their libHCCore.a was compiled with libstdc++ while all the rest were compiled with libc++. I have tried additional linking options in Visual Studio for Mac, but failed with "libstdc++ is deprecated" and "Library –lstdc++ is not found". Here is Microsoft Sebastien Pouliot's advice:

我认为问题是本地库 libHCCore.a 之一是用 libstdc++ 编译的,这导致了错误未定义符号 std::string 而其余的是 libc++.你不能混合两者.使用 libstdc++ 构建在 Xcode 8 中已被弃用,并且在面向 iOS 时在 Xcode 10 中不受支持.C++ 项目现在必须迁移到 libc++,建议将部署目标设置为 macOS 10.9 或更高版本,或 iOS 7 或更高版本....项目依赖项(例如针对 libstdc++ 构建的静态档案)也需要针对 libc++ 重建.https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes?language=对象您需要与供应商联系以获取针对 libc++ 构建的更新请使用 libc++ 重建 libHCCore.a.

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++. You can't mix both. Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later. ... Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes?language=objc You'll need to talk with your vendor to get an updated that is built against libc++ Please rebuild libHCCore.a with libc++.

此问题已通过我们的供应商使用 libc++ 重建 libHCCore.a 得到解决.

This issue has been resolved by rebuilding libHCCore.a with libc++ through our vendor.

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

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