Compiling Mono 3.8.0 on Windows

I want to cross-platform develop c# on Windows with Visual Studio, for the Raspberry Pi running mono. I’m using SQLite for it’s embeddedness and portable database files. Now, while mono has support for SQLite, my version 3.2.3 happens to have a documented bug with Mono.Data.Sqlite. So it can’t work with .NET 4.0 on Windows.

Doom and despair: The mono project does not have a newer installer for Windows. The available one installs the 3.2.3 instead of current 3.8.0. Attempting to use the Mono.Data.Sqlclient.dll from the Raspberry Pi on the Windows machine was no help either and gave me a BadImageFormatException.

Thus, I compileth mono on my Win7 box…

I’ve been mostly following the official guidance [1] from the mono project here, with some extra steps and additional information from outside sources:

  • mono 3.2.3 was already installed
  • downloaded / installed cygwin
  • obtained mono 3.8.0 source tarball and extracted to disk
  • replaced cygwin make.exe with the make.exe from mono 3.8.0 [2]
  • Added the mono 3.2.3 bin folder to the PATH variable
  • In cygwin, did export MONO_PATH=”/cygdrive/c/Program Files (x86)/Mono-3.2.3″ [3]
  • Gave my account NTFS permissions to the <mono_3.8.0_src>\runtime folder
  • Did a ./configure --host=i686-pc-mingw32
  • Followed by make, make install

This took forever, yet worked like a charm.

Some caveats apply, because my Windows machine is 64bit:
I can’t build my application to AnyCPU target [4], and I have to use the 64bit version of the sqlite3.dll – least everything grinds to a halt with more BadImageFormatException.

But yes, I can now code and compile test.exe in VS on Windows, scp the test.exe to the raspberry, and run it there with mono test.exe. Not bad.

C# console application (test.exe) running on Raspberry Pi

Relevant Documents:

[1] http://www.mono-project.com/docs/compiling-mono/windows/
[2] http://shana.worldofcoding.com/en/mono_cygwin_tutorial.html
[3] http://www.mono-project.com/docs/compiling-mono/windows/compiling-with-visualstudio/
[4] http://stackoverflow.com/questions/15917204/badimageformatexception-c-sharp

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s