在 Delphi Win32 中嵌入 Mono
有谁知道如何在 Delphi Win32 应用程序中嵌入 Mono 运行时的具体细节? 官方文档对于 Win32 环境不是很有帮助(www.mono-project.com/Embedding_Mono< /a>)。
更新:
我非常熟悉 Delphi 中静态链接的变幻莫测,并且对 DLL 非常满意。 Mono 本身有依赖关系,所以多一个 DLL 确实没什么大不了的。 关于 FPU 控制字的评论是我关心的问题之一,因为我相信 CG 默认设置与 Microsoft 工具不同。 以下是我认为需要的:
- 从“C”到 Delphi 的头文件翻译(可能不太难)
- Mono DLL 的编译(Mono 附带的那个可用吗?)
- 更好地理解 FPU 控制字 goctha(希望没有)
- 一些来自因尝试此特技而留下战斗伤痕的人的反馈;)
更新(2011 年 6 月 12 日):
如果有人感兴趣,我刚刚在 Google Code 上找到了一个用于在 Delphi 应用程序中嵌入 Mono 的项目:
Does anyone know the specifics of how to embed the Mono runtime in a Delphi Win32 application? The official documentations is not very helpful with regards to the Win32 environment (www.mono-project.com/Embedding_Mono).
Update:
I am very familiar with the vagaries of static linking in Delphi and would be perfectly happy with a DLL. Mono itself has dependencies so one more DLL is really no big deal. The comment about FPU control word is one of my concerns since I believe the CG default settings are different than Microsoft tools. Here is what I believe is needed:
- Header translation from "C" to Delphi (probably not too hard)
- Compilation of the Mono DLL (is the one shipped with Mono usable?)
- A better understanding of FPU control word goctha's (hopefully none)
- Some feedback from someone that has the battle scars from having tried this stunt ;)
Update (6-12-2011):
In case anyone is interested, I just found a project on Google Code for embedding Mono in a Delphi application:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Mono 似乎可以用 mingw 构建,尽管我发现大多数参考文献都是从 Linux 交叉编译的,例如 http://www .mono-project.com/Cross-compiling_Mono_for_Windows
我想说你的首要任务是搜索一个
如果您找到或将其构建为 DLL(以满足 mghie 的正确评论),请编写一个标头(如 Stijn 建议的那样),它就可以工作。
但这并不简单,虚拟机并不是简单的野兽,并且预计会出现常见的跨语言问题域中的问题:库初始化(顺序)、FPU 异常掩码和一般异常处理。 部分原因也是我说“知道在 mingw 之外工作”的原因,研究它在其他编译器中的接口可能会指导如何正确解决这个问题。
请注意,mono 教程有一个 mono lib 初始化程序,但这并不意味着 mono 使用的所有库都已正确初始化。 特别是 mingw 的 libc 可能需要初始化,因为它们通常是通过 ctor 初始化的。 我的(非常初始的)mingw 粘合代码在这里:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/ide/fpmingw.pas?view=markup
另一方面,在 DLL 中,它可能通过 DLL 进行初始化初始化例程。
我自己已经能够将 GDB 构建为库并使用它(尽管在 FPC 中静态地使用它,但我没有动力制作 DLL,因为这是一个选项)
请注意,如果您确实必须自己这样做,那么这不是一个简单的方法。
Mono seems to be buildable with mingw, allthough most references I found crosscompiled from Linux, e.g. http://www.mono-project.com/Cross-compiling_Mono_for_Windows
I'd say your first priority is searching for a libmono dll that
If you find or build it as DLL (to satisfy mghie's correct remark), write a header (like Stijn suggests) it could work.
It won't be trivial though, VMs are not exactly trivial beasts, and expect problems in the usual cross-language problem domains: library initialization (order), FPU exception mask and exception handling in general. Partially that is also why I said "know to work outside of mingw", studying how it is interfaced in other compilers might give pointers how to properly tackle this.
Note that the mono tutorial has a mono lib initializer, but that doesn't mean that all the libs that mono uses are properly initialized. Specially mingw's libc might need initialization, since they are normally initialized via ctors. My (very initial) mingw glue code is here:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/ide/fpmingw.pas?view=markup
On the other hand, in a DLL it might be initialized via a DLL initialization routine.
I myself have been able to build GDB as a lib and use it (statically in FPC though, I didn't have the motivation to make a DLL since that was an option)
Note that if you really have to do this yourself this is NOT an easy way.
这篇 Rudy Velthuis 的文章展示了如何将 C 库链接到 Delphi 的示例。 经过一些工作,应该可以使用这种技术从 Delphi 访问
mono_jit_init
。This article by Rudy Velthuis shows an example how to link a C lib to Delphi. With a bit of work it should be possible to access
mono_jit_init
from Delphi using this technique.您可能想看看http://www.remobjects.com/Hydra.aspx。
You might want to take a look at http://www.remobjects.com/hydra.aspx.