简体   繁体   English

如何在Objective-C中包装庞大的静态C ++库?

[英]How to wrap a huge static C++ library in Objective-C?

I need to use a huge static C++ library in Xamarin.iOS project, I have only one .a and tons of *.h files. 我需要在Xamarin.iOS项目中使用巨大的静态C ++库,我只有一个.a和大量* .h文件。 So I have to wrap headers with Objective-C to run Xamarin Sharpie tool. 因此,我必须使用Objective-C包装标头才能运行Xamarin Sharpie工具。 Any suggestions how to do it? 有什么建议怎么做吗?

To acess the methods from native libraries, you use Mono's P/Invoke functionality which is the same technology that you would use in .NET, which is roughly: 要从本机库访问方法,请使用Mono的P / Invoke功能 ,该功能与.NET中使用的技术相同,大致是:

  • Determine which C function you want to invoke 确定要调用的C函数
  • Determine its signature 确定其签名
  • Determine which library it lives in 确定它所在的图书馆
  • Write the appropriate P/Invoke declaration 编写适当的P / Invoke声明

You can find the more information on this blog here: http://kerry.lothrop.de/c-libraries/ 您可以在以下博客上找到更多信息: http : //kerry.lothrop.de/c-libraries/

CppSharp is another option that is mentioned in the comments CppSharp是注释中提到的另一个选项

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

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