简体   繁体   English

将iOS静态库绑定到Xamarin.iOS并使用dll

[英]Binding iOS Static Library to Xamarin.iOS and using the dll

I am able to successfully create dll file for my Objective-C static library. 我能够为Objective-C静态库成功创建dll文件。 But when I am try to reference that dll from Xamarin.iOS application and compiling, it is giving me lot of error like... 但是,当我尝试从Xamarin.iOS应用程序和编译引用该DLL时,它给了我很多错误,如...

Error MT5210: Native linking failed, undefined symbol: _AudioFileClose. 错误MT5210:本机链接失败,未定义符号:_AudioFileClose。 Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210) 请验证是否已引用所有必需的框架并且本机库已正确链接。(MT5210)

Error MT5210: Native linking failed, undefined symbol: std::ios_base::Init::Init(). 错误MT5210:本机链接失败,未定义符号:std :: ios_base :: Init :: Init()。 Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210) 请验证是否已引用所有必需的框架并且本机库已正确链接。(MT5210)

Error MT5202: Native linking failed. 错误MT5202:本机链接失败。 Please review the build log. 请查看构建日志。 (MT5202) (MT5202)


After this, I tried to link my .a library using Addtional mtouch Arguments. 在此之后,我尝试使用Addtional mtouch Arguments链接我的.a库。 After adding those arguments, I am getting the new error. 添加这些参数后,我收到了新的错误。

Could not parse the command line arguments: Cannot bundle unregistered option '-o'. 无法解析命令行参数:无法捆绑未注册的选项'-o'。

Could someone please help me in resolving this issues. 有人可以帮我解决这个问题。

As Stephane mentioned, there's a IsCxx property on the LinkWithAttribute that you can set to specify that the .a library is a c++ library. 正如Stephane所提到的,LinkWithAttribute上有一个IsCxx属性,您可以设置该属性来指定.a库是一个c ++库。 That'll solve the std::ios_base::Init::Init() error. 这将解决std::ios_base::Init::Init()错误。

To solve the undefined symbol: _AudioFileClose error, you might try adding the CoreAudio or perhaps AudioToolbox framework to the list of frameworks to link against: 要解决undefined symbol: _AudioFileClose错误,您可以尝试将CoreAudio或AudioToolbox框架添加到要链接的框架列表:

[assembly: LinkWith (..., IsCxx = true, Frameworks = "CoreAudio AudioToolbox")]

Hopefully even if that doesn't quite work, it'll get you headed in the right direction. 希望即使这不起作用,它也会让你朝着正确的方向前进。

Finally figured out the error!! 终于找到了错误!!

    [assembly: LinkWith (..., IsCxx = true, Frameworks = "CoreAudio AudioToolbox", LinkerFlags = "-lstdc++ -lz" )]

In iOS Binding Projet 在iOS Binding Projet中

Options > Build > Compiler > Addition Arguments 选项>构建>编译器>添加参数

    -cxx -gcc_flags "-stdlib=libstdc++ -L${ProjectDir} -lMylibrary -force_load ${ProjectDir}/libMylibrary.a”

In my demo application 在我的演示应用程序中

Options > iOS Buidl > Addtional mtouch Arguments 选项> iOS Buidl> Addtional mtouch参数

    --gcc_flags="-stdlib=libstdc++"

By giving the proper flags in all the places it resolved my issue. 通过在所有地方提供适当的标志,它解决了我的问题。

I resolved this problem installing the new version of Xcode. 我解决了安装新版Xcode的问题。 (now 7.1) The error is misleading but now it works! (现在7.1)这个错误是误导性的,但现在它有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM