0

I have created a sample c++ app that uses dynamic linking to embed mono (as described here http://www.mono-project.com/Embedding_Mono) and use C# for scripting. It works well, as long as mono is installed in the global assembly cache (GAC).

Is there a way to bundle mono with my c++ executable so that I can install it alongside my c++ executable ?

I have been looking at mkbundle but it looks like it packages mono with c# apps.

EDIT : answer below reformatted

#include <cstdlib>
_putenv("MONO_GAC_PREFIX=C:\\cygwin\\usr\\local\\bin\\");
mono_set_dirs("C:\\cygwin\\usr\\local\\lib","C:\\cygwin\\usr\\local\\etc");

EDIT : Corrected : I just need to copy/paste mono-2.0.dll in the executable's folder and use mono_set_dirs("C:\\cygwin\\usr\\local\\lib","C:\\cygwin\\usr\\local\\etc"); to force the use of a specific framework

Franco Rondini
  • 10,841
  • 8
  • 51
  • 77
Nelson
  • 249
  • 2
  • 13

1 Answers1

1

Mono consists of 2 distinct parts:

  • the base runtime written in C, embeddable as mentioned in your OQ
  • lots of class libraries, mostly written in C#. These are not embedded together with the runtime, but reside in the GAC

Basically you need to provide your own GAC - this is easyily done by taking it with you into your app folder structure, then setting the MONO_GAC_PREFIX environment variable to wherever you are installed.

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • What happens if I set this environment variable and my users have mono installed ? Wouldn't my custom mono be allways executed instead of my users' mono ? – Nelson May 14 '13 at 01:11
  • Works great, thank you !! #include _putenv("MONO_GAC_PREFIX=C:\\cygwin\\usr\\local\\bin\\"); mono_set_dirs("C:\\cygwin\\usr\\local\\lib","C:\\cygwin\\usr\\local\\etc"); – Nelson May 14 '13 at 01:26