从C#调用UNIX和Linux共享对象文件的.so [英] Calling UNIX and Linux shared object file .so from c#

查看:349
本文介绍了从C#调用UNIX和Linux共享对象文件的.so的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有用C语言编写,并建立在Unix的共享对象文件的方式来从C,#P叫/调用?

Is there a way for a Shared Object file written in C and built on Unix to be called from C# P/Invoke?

或者我需要使用Java或类似的东西?

Or do I need to use Java or something like that?

推荐答案

单必须与本地库从建的dlopen(3)的顶部C#中集成的能力。你只需要使用的DllImport语句库(即'libform.so.5)的名称,然后用一个友好的C#类,它的所有的低层次的东西小心包本机代码和数据类型。 此页面有很多有关如何处理编组指针和其他不安全类型一个很好的概述。

Mono has the ability to integrate with native libraries from within C# built on top of dlopen(3). You just have to use the DllImport statement with the name of the library (i.e. 'libform.so.5'), then wrap the native code and data types with a friendly C# class that takes care of all the low-level stuff. This page has a good overview with lots of information on how to deal with marshaling pointers and other unsafe types.

一旦你得到了你的包装类写的,你可以直接使用,无需担心的事实,它使用一个本地共享库下方。

Once you've got your wrapper class written, you can just use that without worrying about the fact that it's using a native shared library underneath.

这篇关于从C#调用UNIX和Linux共享对象文件的.so的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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