2

I'm on windows 8.1 using VS2012.

I am trying to follow http://www.mono-project.com/docs/advanced/embedding/ to embed the Mono CLR into a C project. After some issue, I have it compiling now. I used the .def file in the article: http://github.com/mono/mono/blob/master/msvc/mono.def Note that this file says: LIBRARY mono-2.0.dll

When I run it, I get an error that the mono-2.0.dll can not be located.

I have mono-3.2.3 installed and I don't see a mono-2.0.dll anywhere.

  1. What mono .dll implements the mono_xxx API (like mono_jit_init)?
  2. Do I need to set env-vars to have the mono folder known to the OS?

I am kind of worried that the document states that mono-2.0 is for older versions and 'mono' should be used - but mono.dll also does not exist...

obiwanjacobi
  • 2,413
  • 17
  • 27

2 Answers2

3

See this answer: Getting/compiling Mono-2.0.dll for embedding

The libraries that you are looking for may be found in the bin directory of the mono installation folder. Actually, after installing mono 3.2.3 there are two libraries in the MONO_INSTALLATION_PATH\bin\ directory: libmonoboehm-2.0.dll and libmonosgen-2.0.dll (you must choose either Boehm or SGen GC implementation)

(Links for Boehm and SGen now redirect to the same web page)

I have never used embedded Mono in Windows (I always use Linux) but perhaps changing in your .def file to those library names your program will work.

For example, for Boehm you must download mono.def and edit it like this:

; file generated by create-windef.pl
LIBRARY libmonoboehm-2.0.dll
EXPORTS

For SGen, just download monosgen.def and edit it in this way:

; file generated by create-windef.pl
LIBRARY libmonosgen-2.0.dll
EXPORTS
Community
  • 1
  • 1
Gooseman
  • 2,102
  • 17
  • 16
  • What is the difference between the two? It still says it can't find the assembly (now libmonosgen-2.0.dll). Do I need to set an environment variable? – obiwanjacobi Sep 21 '14 at 16:44
  • @obiwanjacobi About the first question: The difference is the GC implementation. SGen should be better than Boehm. About the second one: it depends on how have you compiled your program. For example: what paths have you used for `CFLAGS` and `LDFLAGS` options? Or better: what command have you used to compile and link your program? – Gooseman Sep 21 '14 at 17:11
  • I have no idea what CFLAGS and LDFLAGS are. I just setup the project in VS2012. Looking at the command lines for the compiler and linker, no FLAGS (C or LD) are used. But I added the bin folder to the PATH environment variable and I no longer get that error (now a totally different one ;-). – obiwanjacobi Sep 21 '14 at 17:24
  • @obiwanjacobi I thought you were using gcc not Visual Studio. I guess if you have for example libmonosgen-2.0.dll in the same path as your .exe file it should also work. – Gooseman Sep 21 '14 at 17:38
  • 1
    @Gooseman: can you edit [the page](https://github.com/mono/website/blob/gh-pages/docs/advanced/embedding/index.md) in the Mono docs to fix the outdated information? Might save the next one that stumbles over this some time :) – Alexander Köplinger Sep 23 '14 at 08:55
  • @AlexanderKöplinger I did not even think about it xD. I will do it this weekend (I want to verify if everything is working on Windows, for the obiwanjacobi question and comments there could be something else wrong) – Gooseman Sep 23 '14 at 09:23
  • This is indeed the answer. Important to note is that the Mono install is 32-bits. I also had some issues with that - mixing up 32- and 64-bit dll's. Next piece of information would be a working manual on how to get a x64 of libmonosgen-2.0.dll... – obiwanjacobi Sep 27 '14 at 08:06
  • @obiwanjacobi AFAIK there is no 64-bit version of Mono for Windows (you could try to compile one by yourself but for sure there will be issues) – Gooseman Sep 29 '14 at 00:22
  • @Gooseman I know! That is why I called for a "working manual" because the mono docs are usually hopelessly out of date... ;-) – obiwanjacobi Oct 01 '14 at 07:13
0

In your property manager in visual studio, just do a post build events to copy your dll to your executable folder. iirc the dll is in the etc folder for embed mono.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 10 '21 at 18:15