构建用作.net库的本机c ++ [英] Build native c++ for use as .net library

查看:153
本文介绍了构建用作.net库的本机c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对我感兴趣的功能的c ++源代码。

I have the c++ source code of functionality which is appealing to me.

需要什么努力/工作以便从.net应用程序或将此代码构建为.net程序集(最好是c#)?

What effort/work is involved/required in order to either reference this from a .net application or build this code as a .net assembly (preferably c#)?

这是我第一次尝试移植代码,所以请逐一分解您的答案。

This is my first attempt at porting code, so please breakdown your answer for me step by step.

推荐答案

有几种方法。


  1. PInvoke

  2. 在C ++本地代码(使用C ++本地代码创建静态库)和C ++ / CLI生成的程序集中创建C ++ /应用程序。

  3. COM,即使用interop(这在所有选项之间很难)

在我的建议最简单的方法是使用选项2,但你需要照顾适当的封送。

In my suggestion easiest way is to use option 2, but you need to take care of proper marshaling.

这篇关于构建用作.net库的本机c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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