寻找教程或基本信息,让我开始在C#实现C / C ++ API对于初学者 [英] Looking for tutorial or basic information to get me started on implementing C/C++ API in c# for beginners
问题描述
我在使用MonoDevelop的做我的工作学习C#/。NET的相当早的阶段。我遇到这是在C语言开发或有时C ++ API一些的。我一直在寻找信息,让我开始实施用C或C ++这样我就可以用它们为我的C#项目的API。我没有任何具体的code给你看现在,我需要的是在正确的方向指出。
I'm in fairly early stages of learning c# / .NET using MonoDevelop to do my work in. I've come across some API's which were developed in c or sometimes c++. I've been looking for information to get me started on implementing APIs written in c or c++ so I can use them for my c# projects. I don't have any specific code to show you right now, what I need is to be pointed in the right direction.
下面是我仔细研读地方取样:
Here is a sampling of places I've perused:
我想在C#实现C / C ++ API。我做了一些研究,但我在起步的麻烦。
I am thinking about implementing a c/C++ API in C#. I have done some research, but I'm having trouble getting started.
HTTP://www.$c$ cproject.com/Articles/1285/Calling-API-functions-using-C (一个有些过时文章,看起来是可行的,但似乎并没有走得很远。)
http://www.codeproject.com/Articles/1285/Calling-API-functions-using-C (a somewhat dated article, looks doable, but doesn't seem to go very far.)
http://www.csharpfriends.com/Articles/getArticle.aspx?条款ArticleID = 219 (一些基础知识,而是正在发生的事情没有太多的细节。)
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=219 (some basics, but not much detail about what is going on.)
发现了一些东西,在这样:
C API到C#GUI
(这看起来不错farily)
found some stuff on SO: C api to C# GUI (this looks farily good)
<一个href=\"http://stackoverflow.com/questions/9747607/c-apivs-2005-integrate-into-c-sharp-vs-2010project\">C-API(VS 2005)集成到C#(VS 2010)项目
(无应答给出)
C-API(VS 2005) integrate into c# (VS 2010)project (no answer given)
从C#谈论到C
(看起来不错,约PInvoke的一些东西)
talking to C from C# (looks good, some stuff about Pinvoke)
不管怎样,我有点不知所措,并且可以使用一些指导做好让我开始。这也许是太多的一个小白为byte [原文]了吗?
Anyway, I'm a little overwhelmed, and could use some guidence to get me started. Maybe this is too much for a noob to byte [sic] off?
任何帮助很多AP preciated。
CHEERS
Any help is much appreciated. CHEERS
推荐答案
尝试痛饮 - 它是一个工具为许多语言创建围绕C和C ++ code包装。
Try SWIG - it is a tool for creating wrappers around C and C++ code for many languages.
我已经收到了良好效果使用了很多次。基本上你只定义要包裹其中C和C ++ code文件/库和SWIG生成相应的C#类(和一些样板code),你可以简单地添加到您的C#项目(当然你必须也编译C / C ++的一部分,使其成为一个DLL)。
I have used it many times with good results. Basically you just define which C and C++ code files / libraries you want to wrap and SWIG generates corresponding C# classes (and some boilerplate code) which you can simply add to your C# project (and of course you have to compile the C/C++ part also and make it a DLL).
例如。您可能有过班的小C ++库
Eg. you might have small C++ library which had classes
class Foo { public: int myMethod(Bar& bar); }
class Bar { ... }
SWIGing后,你的C#code看起来是这样的:
After SWIGing, your C# code would look something like:
Bar bar = new Bar();
Foo foo = new Foo();
int result = foo(bar);
这篇关于寻找教程或基本信息,让我开始在C#实现C / C ++ API对于初学者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!