使 C++CLI 应用程序在 WIndows 和 Unix 上可移植的步骤是什么?
我有一个客户端,它有一个托管 C++ DLL 库,需要能够在 Unix 上运行。除了从外部进程/线程接收输入的文件之外,其中没有太多对 .NET 特定代码的引用。该项目当前在 Visual Studio.NET 2010 上编译。为了实现这一目标,需要遵循哪些步骤?显然,我需要在 Unix 端创建 makefile。我需要做的另一件事是替换使用 .NET 属性的类以使用 getter/setter(这是最好的方法吗?)。他们的前端 GUI 目前是一个 Excel/Visual Basic 应用程序,调用此 DLL 库对一组数据执行计算。然而,他们也将重写前端(不确定他们将使用什么技术)。我假设我需要做的另一件事是用本机类型替换代码中的 CLI 类型。到目前为止我的假设正确吗?还有哪些更大的事情需要做?谢谢!
I have a client that has a managed C++ DLL library that needs to be able to run on Unix. There aren't a lot of references to .NET specific code in there except for the files that receive the inputs from an external process/thread. The project is currently compiled on Visual Studio.NET 2010. What are some steps to follow in order to make this happen? Obviously, I will need to create makefiles on the Unix side for example. Another thing I will need to do is to replace classes that are using .NET properties to use getters/setters (is this the best way to go?). Their front end GUI is currently an Excel/Visual Basic application that calls this DLL library to perform calculations on a set of data. However, they are going to rewrite the front-end as well (not sure what technology they are going to use). I'm assuming that another I will need to do is replace CLI types in the code with native types. Am I correct in my assumptions so far? What other bigger things will need to be done? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
托管代码与本机代码有很大不同 - 您将需要完全重写 DLL 依赖于 .NET Framework 的所有部分,假设安装 Mono 或类似的东西不是一个选项。然后将其编译为 Linux 的本机 C++。一些 .NET 代码可以轻松转移,例如使用集合到标准容器,但有些代码则不能 - 例如,您必须从头开始设计资源所有权策略。我还担心调用代码将如何更改以在 Unix 上运行(如果它需要托管接口)。
Managed code is quite different to native code- you will need to completely re-write all parts of the DLL that depend on the .NET Framework, assuming that installing Mono or something like that isn't an option. And then compile it as native C++ for Linux. Some .NET code will transfer over easily, like the use of Collections to the Standard containers, but some of it won't- for example, you'll have to devise the resource ownership strategy from scratch. I would be concerned also about how the calling code is going to be altered to run on Unix, if it expects a managed interface.