我知道.NET内核的目标是跨平台开发,但是我正在寻找向后兼容性。如果我有一个可用的linux库(也许是旧版),并且希望从用于linux平台的.NET核心应用程序中调用它的功能。有可能吗?
I understand that aim of the .NET core is for cross platform development, but I am looking for backward compatibility. If I have a linux library available (maybe, legacy) and I want its functions to be called from .NET core application for linux platform. Is it possible?
我不是在谈论ASP.NET内核,我需要它用于桌面应用程序。
I am not talking about ASP.NET core, I need it for a desktop application.
推荐答案查看SWIG。这是包装共享库的一种简单方法,它可以为您生成所有P / Invoke代码,并在.so库和C#代码之间映射任何头文件(认为结构)。我们在要使用的.so库周围创建了一个简单的cpp包装器,然后让SWIG发挥作用。现在,我们有了一个C#库,可以从调用我们的Linux库函数的.Net代码(一个简单的控制台应用程序)中调用。我们已经在运行Ubuntu,CentOS和Debian的Unix主机上的PI上成功地做到了这一点。 www.swig/
Look at SWIG. It is a simple way to wrap a shared library and it generates all of the P/Invoke code for you as well as maps any header files (think structs) between your .so library and your C# code. We created a simple cpp wrapper around the .so library that we wanted to use and then let SWIG do its magic. We now have a C# library that can call from our .Net code (a simple console app) that invokes our linux library functions. We have done this on a PI, on unix hosts running Ubuntu, CentOS, and Debian with great success. www.swig/
更多推荐
是否可以从.NET Core在Linux平台上调用共享库(.so)?
发布评论