Embedding Mono in Delphi Win32

Does anyone know the specifics of implementing a Mono environment in a Delphi Win32 application? White papers are not very helpful regarding the Win32 environment ( www.mono-project.com/Embedding_Mono ).

Update:

I am very familiar with the vagaries of static binding in Delphi and am very good at DLLs. Mono itself has dependencies, so another DLL doesn’t really matter much. Commenting on the FPU control word is one of my problems, as I believe that the default CG settings are different from Microsoft tools. Here is what I consider necessary:

  • Translation of the title from "C" to Delphi (perhaps not too hard).
  • Compiling the Mono DLL (is there one of them used by Mono?)
  • Better understanding of the goctha FPU control word (hope not)
  • Some feedback from someone who has battle scars by trying this trick;)

Update (6-12-2011):

If anyone is interested, I just found a project in Google Code for embedding Mono in a Delphi application:

monoemb4delphi

+6
winapi delphi mono embedding
source share
3 answers

Mono seems to be able to be created using mingw, although most of the links I found are cross-compiled from Linux, for example. http://www.mono-project.com/Cross-compiling_Mono_for_Windows

I would say that your first priority is to look for the libmono library, which

  • does not use cygwin (trust me)
  • known to work, also outside of mingw (avoid possible mingw specific c ++ mangling if using c ++)
  • Preferably comes with a readable header.

If you find or create it as a DLL (to satisfy mghie's correct remark) write a header (e.g. Stijn), it may work.

This will not be trivial, although virtual machines are not exactly trivial animals and expect problems in the usual areas of problems in different languages: library initialization (ordering), FPU exception mask and exception handling in general. In part, this also suggests that I know that β€œI know how to work outside of mingw,” exploring how it interacts with other compilers can give pointers how to handle this correctly.

Please note that the mono-tutorial has a mono lib initializer, but this does not mean that all libraries that use mono are correctly initialized. Specifically, mingw libc may need initialization, since they are usually 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 can be initialized using the DLL initialization procedure.

I myself was able to build GDB as a lib and use it (statically in FPC, although I had no motivation to create DLLs, since that was an option)

Please note: if you really need to do this yourself, this is NOT an easy way.

+6
source share

This article by Rudi Veltius shows an example of how to associate C lib with Delphi. With a bit of work, you can access mono_jit_init from Delphi using this technique.

+2
source share

You might want to take a look at http://www.remobjects.com/hydra.aspx .

+2
source share

All Articles