Take the 2-minute tour ×

I am interested in hearing about peoples experience with embedding mono (open source implementation of .NET) in a C/C++ application. How is it to distribute such an application and what are the dependencies? I have tested on OS X and mono comes as a huge framework (hundreds of MB). Do users of my app all need this big framework or can it be stripped down or everything be compiled into the main executable.

I previously have experience with embedding Lua in a C++ app, and that works really well because I can link statically the whole lua interpreter in with my main executable. So I have no external dependencies. Is it possible to do something similar with mono?

Any Lua people here who can comment on how they found mono compared to Lua?

PS: By embedding I mean a C++ application which initializes a mono environment and loads a .NET assembly and executes it and then allows for communication between say C# code in assembly and C++ methods in main executable.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You should probably also take a look at Mono's Small Footprint page that describes how you can embed a smaller runtime. Heck, they do it themselves with Moonlight.

I hope that helps.

share|improve this answer
Thanks. If I understand correctly, is mscorlib.dll and the JIT the only things that are required to get mono embedded? Is there a way to statically link mscorlib.dll? –  Adam Smith Feb 19 '09 at 10:34
Mono allows you to completely statically link your code, so you probably don't even need the JIT. Have a look at their iPhone implementation. –  Dave Van den Eynde Feb 19 '09 at 11:01

This is 2 years old question. So situation may become different now.

For me, most important point was GC. I embedded Lua for interactive-apps and games, because incremental GC required. Currently Lua 5.1 has precise, incremental GC, but I couldn't found any proof of incremental or precise GC on Mono. So memory will leak (even it's very tiny!), and apps will struggle intermittently.

People says GC pause can be solved by tuning some parameters and pooling objects, but as I experienced, It never be solved without any kind of distribution GC load over time approach in GC. Generational GC is one of distribution algorithm, but it's too rough, and almost not helpful.

Because you can't control lifetime pattern or reuse instance by pooling the objects used in code that not yours. (such as basic class library)

So I don't recommend the C# platform (Mono or .NET, at least yet) for interactive/(soft)realtime apps.


I don't know whether any incremental/concurrent approached GC is presented on Mono or .NET. If you can sure about they offer the kind of GC, of course, it's fine to use :)

share|improve this answer
Even with over 2000 games built on Mono in the iOS App Store? –  Dave Van den Eynde Jun 25 '11 at 19:34
@Dave How about number of games in C/C++? :) The number doesn't proof presence of incremental GC. If you don't need serious interactivity, you can go for old GC. But if your users care about even very tiny time of pause, you'll regret. –  Eonil Jun 26 '11 at 6:37
@Dave We can make game with anything! Just possible to make? is more pointless and moot. In old days, (and maybe still yet) there were text-only games made with ASM. Somebody makes a game with only sounds. If your games are these games, well.. we don't have to consider anything. But, if you're talking about modern games (have smooth animations and interactive graphics), yes that's what I'm saying. Well-made GC is required to this graphics. In my opinion, incremental GC is the biggest benefit of Lua vs Mono unless someone clarify Mono has nice GC. –  Eonil Jun 26 '11 at 19:32
@Cygon Well, about the hiccups, it's just problem about quality basis. You may fine with it, but your users may not. If you're making hard-core fighting action or music based game (a.k.a rhythm action) even a little tiny hiccups won't be forgiven because most users can feel difference of 1/60 second. Anyway, thanks for pointing about concurrent GC on Mono. Can I have the link about their GC? I want to know kind of GC they are using. –  Eonil Jan 11 '13 at 9:05
You'll find it in just about any release announcement about Mono 3.0. Here's a link to the blog of the developer describing it in detail: schani.wordpress.com/2012/12/21/sgen-concurrent-mark - In short, the "Mark" phase is now concurrent and the sweep phase is incremental similar to Lua. –  Cygon Jan 12 '13 at 9:30

Your Answer


