[Mono-dev] Compiling mono on windows for developing (not running)
Alex J Lennon
ajlennon at dynamicdevices.co.uk
Sun May 4 10:31:06 UTC 2014
On 26/04/2014 10:37, Martin Thwaites wrote:
> Thanks Edward,
> I'll have to wait until someone puts a guide together about developing
> on windows as I am seriously out of my depth. I've spent about 2
> evenings so far trying to get mono to build in cygwin, but coming up
> with various errors that googling isn't solving.
I've been trying to do the same thing for the past few days as I can't
find a binary release of Mono 3.4.0 for Windows and I want to build
locally with 3.4.0 to remote debug on my ARM targets which are also
There seem to be a variety of tutorials out there which are all helpful
but none has quite worked for me.
I am working on some documentation at present, which I'm going to upload
to a wiki somewhere or other when I have it finished and polished up.
I've just seen your email though, so these work-in-progress notes may be
of help to you now.
If they are of help I'd appreciate your feedback with what worked, any
corrections/clarifications/additions so I can improve this.
Thanks, Best Regards,
Building Mono on Win32/Cygwin
(1) Install Cygwin
Run setup-x86.exe to install Cygwin -
Follow instructions from "Compiling Mono on Windows" to install needed
Also nice to haves: wget, zip patch, openssh, vim
NOTE: In addition to this you will need the following packages as per
2) Install working Mono binaries
Use the installation executable from go-mono.com, at time of writing:
For me this gives a working Mono in C:\Program Files (x86)\Mono-3.2.3 on
a Windows 8.1 / x64 host
(3) Grab new Mono sources
(a) From source tarball
(i) Download and Extract
Download the tarball you wish to use from
NB. I have had different build issues with different Mono releases at
different times, on differing platforms,
to paraphrase Mrs Gump, "Mono is like a box of chocolates, you never
know what you are going to get"
At the time of writing we are using 3.4.0:
Do not extract the source tarball with native Window tools as this
appears to affect line endings, which will cause problems.
To extract within Cygwin first run the Cywgin environment (Cygwin
terminal on your start bar) and extract with,
tar xjvf mono-3.4.0.tar.bz2
This will give you a mono-3.4.0 directory
(ii) Mount destination
Create a destination folder, where we are going to install the newly
built Mono, in this case C:\Mono-3.4.0
Copy across files from your existing installation (e.g. Mono-3.2.3) to
the 3.4.0 folder to give us a baseline
NOTE: It is important not to have spaces in the path as otherwise the
Mono build will fail, so we're putting this in the root of C: for this
(From my reading it is also likely to be important not to
have Windows user names with spaces in them, so a heads-up there...)
Mount this folder as /usr/local with
mount "C:\Mono-3.4.0" /usr/local
As a check you can 'ls /usr/local' which should show the files that you
have in C:\Mono-3.4.0
(iii) Autogen the build
./autogen.sh --prefix="C:\Mono-3.4.0" --with-preview=yes
(iv) Configure the build
At the end of this process, with the defaults, you should see something like
mcs source: mcs
GC: sgen and bundled Boehm GC with typed GC and
Engine: Building and using the JIT
LLVM Back End: no (dynamically loaded: no)
.NET 2.0/3.5: yes
.NET 4.0: yes
.NET 4.5: yes
JNI support: no
libgdiplus: assumed to be installed
zlib: system zlib
(v) We're ready to build mono
You can go ahead and try 'make' now but at the time of writing
(03/05/2014) there is a problematical interaction between the Cygwin
headers and the Mono build
This will lead to an error along the lines of,
conflicting types for 'PEXECUTION_STATE'
In file included from
A workaround is to edit the Cygwin header file ntapi.h (e.g.
rename PEXECUTION_STATE to PEXECUTION_STATE_KLUDGE, say.
(this will take some time )
(vi) Install mono
At the time of writing (04/05/2014) there is a missing file in the Mono
3.4.0 release tarball. This causes installation failure.
To add the missing file create a new file in mcs/tools/xbuild/targets/
This should contain the following
<Import Project="..\Microsoft.Portable.Core.props" />
<Import Project="..\Microsoft.Portable.Core.targets" />
Then ensure that /usr/local is correctly mounted as per 3(b)(ii) and run
(vii) Fix "missing" mono.exe
The installation removes the existing mono.exe from the
C:\Mono-3.4.0\bin directory and does not seem to copy across a new version
Within the Cygwin environment there is a "mono.exe" which is a symbolic
link to mono-sgen.exe, which is rebuilt.
So, assuming that under Win32 the mono.exe is a stub executable (which
it seems to be as it is small) it should be reasonable to copy across
mono.exe from the older mono installation
e.g. Copy C:\Program Files (x86)\Mono-3.2.3\bin\mono.exe to
(vii) Check installation
Open a Windows cmd box, cd to C:\Mono-3.4.0 and run
This should show something like
Mono JIT compiler version 3.4.0 (tarball)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
Notification: Thread + polling
LLVM: supported, not enabled.
(viii) Enable Xamarin Studio to add the new Mono runtime
If you to to Xamarin Tools->Options and try to add the Mono-3.4.0 folder
it will fail to detect Mono.
This is because of the presence of an installed symlink file, bin\mono
So, for example, delete the file C:\Mono-3.4.0\bin\mono and you will
then be able to add the runtime to Xamarin Studio
There is an archive of the binaries resulting from my build here,
NOTE: That Mono 3.x fails to build projects for me with recent Xamarin
Studio builds giving the error
Build failed. Could not find type 'System.Globalization.SortVersion'.
This appears to be addressed in this commit which is not present in 3.4.0
The workaround is to use an older version of Xamarin Studio as discussed
i.e. Download Xamarin Studio 4.2.3 from your account at Xamarin.com with
"view all versions"
NOTE: You may then get a build error about UNC paths
error : Error building target GetReferenceAssemblyPaths: UNC paths
should be of the form \\server\share.
This appears to relate to extra \\'s in configuration files as discussed
The workaround is to go to project options and unback "Use MSBuild
engine" at which point you will be able to compile and debug applications
(b) From SVN - TBD
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list