跨平台本机/托管接口
我有一些本机 C++ 库,因此我需要公开托管(在本例中为 C#)代码。我需要尽可能加快速度。
我想使用一些类来简化交互,这意味着混合代码,但这不是必需的。
要求是跨平台兼容,最坏的情况是 Windows 和 Linux。因此,标准 /clr 是不可能的。
我的选择是 /clr:pure 或 /clr:safe,或者将 Mono 嵌入中间层。我的问题是哪个会更好(最佳性能以及易于开发和后期使用)。
我需要使用的库大量使用指针,偶尔还使用共享指针,这让我认为 C++/CLI 层会更容易。我编写了一个简单的应用程序来测试某些对象的使用,并使用 /clr:pure 对其进行编译,它没有链接到本机模块,但可以在 Windows 和 Linux 下运行。
I have a few native C++ libraries and such that I need to expose to managed (C#, in this case) code. I need to get as much speed out of it as possible.
I would like to use some classes to simplify the interaction, which means mixed code, but that's not a requirement.
What is a requirement is that it be cross-platform compatible, to Windows and Linux at worst. Thus, standard /clr is out of the question.
My options are either /clr:pure or /clr:safe, or embedding Mono into a go-between layer. My question is which will be better (best performance and ease of development and later use).
The libraries I need to work with make heavy use of pointers and occasionally shared pointers, which made me think the C++/CLI layer would be easier. I wrote a simple app testing use of some objects and compiled it with /clr:pure, it didn't link into the native module but did run under both Windows and Linux.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 P/调用。
从我所看到的情况来看,使用“pure”会使速度慢很多,尤其是数字运算的东西(加密)。
Use P/Invoke.
Using 'pure' will make it a lot slower from what I have seen, especially number crunching stuff (encryption).