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.
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
本文详细介绍了如何在Windows上使用Visual Studio编译Mono 3.8.0,并解决了与SQLite兼容性的问题。作者通过替换make工具、配置环境变量等步骤成功实现跨平台编译。


被折叠的 条评论
为什么被折叠?



