简体   繁体   English

Visual Studio中C#IOS项目中的c ++库

[英]c++ library in C# IOS project in Visual studio

I have created a C++ static library for ios (XCode 6.1) in visual studio. 我在visual studio中为ios(XCode 6.1)创建了一个C ++静态库。 But when I compile this project, the output .a file is getting created in Mac machine and not getting copied back to Windows. 但是当我编译这个项目时,输出.a文件是在Mac机器上创建的,而不是被复制回Windows。 My concern is that how can I refer this static library in an iOS C# application project in Visual studio? 我担心的是如何在Visual Studio的iOS C#应用程序项目中引用这个静态库?

So you have several options here, what you need to do is to have a Dll that contains the native .a library and the resources/code to interop with the native c++ library (and reference that Dll in your Visual Studio Xamarin.iOS project). 所以你有几个选项,你需要做的是拥有一个包含本机.a库的Dll和与本机c ++库交互的资源/代码(并在Visual Studio Xamarin.iOS项目中引用Dll) 。 You can use a Xamarin iOS Binding project as a container and one of the following options 您可以将Xamarin iOS Binding项目用作容器,并使用以下选项之一

  • You can use swig to wrap the c++ lib and there is actually a video from Xamarin University lighting lectures from Chris Van Wyk that describes the process. 你可以使用swig来包装c ++ lib,实际上有来自Chris Van Wyk的Xamarin大学照明讲座的视频描述了这个过程。
  • You can use Mono CppSharp to wrap the library (My personal favourite easier to use than swig). 您可以使用Mono CppSharp来包装库(我的个人喜欢比swig更容易使用)。
  • You can write your own c wrapper around the c++ library and P/Invoke that from C# 你可以在c ++库中编写自己的c包装器,从C#编写P / Invoke
  • You can write your own Objective-C wrapper around the c++ library and use a Xamarin.iOS Binding project to interop with it. 您可以围绕c ++库编写自己的Objective-C包装器,并使用Xamarin.iOS Binding项目与其互操作。

    Hope this helps. 希望这可以帮助。

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

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