I have been trying (I use this term loosely, since I’ve probably only spent a slightly long working day on it), for a couple of weeks now to write a C++ application which spins up an embedded Mono runtime environment, and executes some C# code – my aim being to write a game engine which uses C# as its scripting language.
All of this would have been quite simple had I not decided that I want my engine to be 64-bit from the get-go, and so started my long journey to getting mono-embedded working.
First, I was under the impression (which turned out to be right), that I would need to build all of mono from source, so I checked out the source code (which took a long time my mono folder is 1.72GB on disk, although some of that must be binaries surely?), only to find that only the runtime can be built from Visual Studio (the framework and compilers must be built from cygwin – autotools, YUCK!). So I then asked the community how much I needed to build, and was told I only needed a 64-bit runtime. So, I tried to build the runtime in Visual Studio 2010, but couldn’t, so I moved to Visual Studio 2008, where I eventually managed to get the runtime compiling, but found there was a bug in the code which I later fixed on the advice of one of the community members.
So finally, I had a working runtime, only to find that the installed version of the framework I had was too old (it seems the source code I downloaded is much newer than the released 2.6.4 version of mono). So, I had to bite the bullet and install cygwin (which took me a couple of attempts to get right). Anyhow, nearly two hours later and the code is built, installed, and the test embedding application works like a charm.
Thanks especially to shana for this article on building mono for windows. If you’re going to follow it, I recommend installing the cygwin version of make, rather than 3.80 (the article is a little old, and cygwin have fixed their make).
Anyhow, it is way past my bed-time on a Sunday, but I’ll post more about my experiences embedding mono in the future.