Click here to Skip to main content
13,045,019 members (39,074 online)
Click here to Skip to main content
Add your own
alternative version


53 bookmarked
Posted 12 Jul 2007

Building Mono on Windows: the final battle

, 12 Jul 2007
Rate this:
Please Sign up or sign in to vote.
Defines full process of building Mono on Windows with Cygwin
This is an old version of the currently published article.


The article gives the full step-by-step guide on building Mono on Windows using Cygwin. There are number of article over the net that give the same tutorials, but no one of them gave me desired result due to different small uncertainties.

Two great articles I used as a base for my build process are:


Mono is a free open-source .NET implementation, primary oriented on Linux word, but available also for MacOS and Windows. It contains a lot of nice stuff like own C# compiler (mcs), .NET runtime (mono), .NET class library, integration with Gtk, IDE (MonoDevelop) etc.

Building process

The build process is the same as described in the articles:

  1. Installing stable Mono for Windows
  2. Installing Cygwin
  3. Getting sources from SVN
  4. Building mono with mono in cygwin

The difference is that the current article allows you to easily use compiled mono without cygwin. Also some moments mentioned only in one of articles and omitted in other are highlighted.

Installing stable precompiled Mono

This is the easiest step :).

It is available here:, just use the Stable installer.

If you want some advanced experience in the future (I plan to try building MonoDevelop), combined installer is recommended. It's available from the Novell forge:, the file is called "mono-x.x.x-gtksharp-x.x.x-win32-exp-x.x.exe" .

Important note. Download from the first link by default suggests C:\Program Files\Mono-x.x.x directory. You should alter it so that the destination path doesn't contain spaces. C:\mono\Mono-x.x.x is recommended. Here and everywhere in the article x.x.x stands for the mono version you have downloaded.

Installing Cygwin


It's highly recommended that your windows login name doesn't contain spaces. If it does, bad for you, but you can fix this (, page 2, question 13).

If you have unsuccessful attempts to install cygwin in the past, remove it first. See (section 1) for details.

Installing Cygwin

I suggest using the latest build, always available from the

Download the "setup.exe" file, put it somewhere on the disk and run it. Make sure to have enough free space on this disk (at least 100M).

After the setup is ran, select the default settings (destination path, UNIX line separators, etc.), pick some mirror from the list and the list of available packages will be displayed to you.

Using the View button, switch to the Full view mode. No you see all the packages. Most of them have 'Skip' option. Select the following packages:

  • automake
  • bison
  • gcc
  • gdb
  • gettext
  • intltool
  • libiconv
  • libtool
  • pkg-config

Make sure not to forget any of them.

DO NOT select make and glib packages. If you're interested why – read here: (Installing cygwin).

If you're OK with vim, select it too.

Now click the Next button and wait until download and configuration processes are finished.

Configuring Cygwin

Using the icon from the start menu or from the desktop, run the cygwin bash shell.

If you're domain user, the warning saying that not all users and groups from the domain are in your etc/* files. The warning hints you on fixing this by running two commands. Just do it. Then exit cygwin (by typing exit and pressing Enter).

Run the cygwin again. Now it should create the /home/your_name directory (the path is relative to the cygwin root directory) and copy 4 files to it: .bash_history, .bash_profile, .bashrc, .inputrc. Periods in the beginning of their names indicate that these are UNIX hidden files.

Until you are familiar with vi/vim, you need some good text editor. Saying 'good' I mean "something a bit cleverer than Notepad", as you have to edit files with UNIX-like line separators. The difference is that the UNIX files use '\n', while Windows utilizes '\n\r', and this is a problem. So, I recommend Notepad++, that is available here: It will help us once again later.

So, if you don't like (don't know) vim, exit the cygwin and install some 'clever ' notepad. Open the c:/cygwin/home/your_name/.bashrc file and add the following text to the end:

#Environment Variables for Mono
export PATH="/usr/local/bin:/usr/local/lib:$PATH:/usr/local/icu/bin"
export ACLOCAL_FLAGS="-I /usr/share/aclocal"
export CPPFLAGS="$CPPFLAGS -I/usr/local/include"
export LDFLAGS="$LDFLAGS -L/usr/local/lib"
export CC="gcc -mno-cygwin"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig"
export LD_LIBRARY_PATH="/usr/local/lib:/usr/lib"
export MONO_PATH="/usr/local/lib:/usr/lib:$MONO_PATH"
export MONO_CFG_PATH="/usr/local/etc:/usr/etc:$MONO_CFG_PATH"

#Environment variables for .NET if not already in your Windows PATH
#These variables could be needed by older Mono build systems
#export PATH=$PATH:`GetNetSdkLocation -cs msnet_1.1`/v1.1.4322
#export PATH=$PATH:`GetNetSdkLocation -cs msnetsdk_1.1`/Bin
(thanks to Kevin Shockey's article)

This will set necessary environment variables every time you run cygwin. Exit cygwin and run it again.

Installing extra packages

Some necessary packages are not available from the cygwin repository (like perl-XML-Parcer), other (like make) don't suite our goals. So now we will install them manually from the tarballs.

Go to the bash and type

mkdir -p /download/mono

It creates directories download and download/mono in the cygwin root directory. Of course, you can do the same from the Windows explorer.

No download proper version of make from the mono official site: Save the file to the c:/cygwin/download directory. Also download there the perl-XML parser:

Now we have to install (actually simply extract) them:

tar -xjvf /download/perl-XML-Parser-2.34-1.tar.bz2

Seems not very beautiful, really. But bash environment (as well as windows cmd, btw) provides nice auto-completion on Tab press. So you can type tar -xjvf /d, then click Tab and download will be auto-completed. Then print /perl and click Tab once again. Voilà.

Extract make in the same way.

Final cygwin preparations

So, a little tuning is left.

At first, we will mount mono bin, lib and other directories into our cygwin environment. It's done by typing

mount -s c:/mono/Mono-x.x.x /usr/local

Check you /usr/local directory through the Windows explorer. The bin, lib and etc directories are empty. And no go to them in the cygwin (cd /usr/local/bin) and explore their contents (dir). You see that they reflect appropriate mono directories. Now mono installation exist in the cygwin environment, is visible from there and can be (and will be) used.

Type mono --version to verify it. You must see information about existing mono.

No, we have to substitute Microsoft compiler (probably installed on your machine) with mono's mcs. It's done by making link to mcs that substitutes the csc.exe calls.

Type ln -s /usr/local/bin/mcs ./csc.exe. Then check result by typing csc.exe --version. The result should be the same as for the mcs --version.

OK, we are ready with cygwin.

Installing subversion

Subversion is the version control system, child and conqueror of the CVS. We need it to obtain the latest mono and mcs source code.

You can choose between the command-line tool (original distribution) or the GUI implementation (TortoiseSVN).

Command-line svn

Download and install svn from here: Typically only the last but one version is published as windows installer, while the latest one is in zip. I suggest downloading both, installing svn with installer (this sets some environment variables), and then replacing installed files with those from the latest zip.

No call cmd and check that svn is installed by typing svn --version.


TortoiseSVN is a nice and easy to use Windows subversion client. It integrates with Windows explorer. It can be downloaded from here:

Making repository checkout and sources export

Now we have to check out the mono and mcs repositories, it means get mono and mcs sources from the special subversion server.

Using the command-line client, checkout is done with svn co path-to-repository from the command line in the directory where you want to get sources. Using TortoiseSVN – just by right-clicking on the directory, selecting Checkout and entering the path to the repository.

Create some directory for the sources and 2 directories inside it, called mono and mcs. You will need approximately 200M of free space.

Now make checkouts: svn:// – to mcs, svn:// – to mono.

Note. If you get error messages, change svn:// in the addresses to the http://.

The checkout process is rather long.

Now we have to export received sources to cygwin directory. Exporting means copying all source files without subversion service files. Command-line client does it by executing

svn export . path-to-export
in the working copy (directory where you've done check out). TortoiseSVN does it from the context menu.

Export both source directories to c:/cygwin/download/mono/mono and c:/cygwin/download/mono/mcs correspondingly. Don't create target directories if using svn, on the contrary, create them manually before exporting with TortoiseSVN.

The problem. By default your subversion client is configured to use CRLF line separators (Windows-style). And this will be the problem, especially with one file – mkinstalldirs from the mcs repository. There are 2 solutions for this problem:

1. If you use command-line client, use the following command for export:

svn export . c:\cygwin\download\mono\mcs --native-eol LF
2. Unfortunately, TortoiseSVN doesn't allow you to specify export switches. So, in this case open the c:/cygwin/download/mono/mcs/mkinstalldirs file in Notepad++ and click the Format > Convert to UNIX format. Then save the file and close the editor.

Fine, we are ready to build.


Standard build process consists of 3 steps:

  1. Configuring build options
  2. Building (compiling)
  3. Installing (copying compiled files)

First, from the cygwin bash shell go to the /download/mono/mono directory. Type

./ --prefix=C:/mono/Mono-x.x.x --with-preview=yes
(of course substitute the path to your real mono installation)

The trick is that we use absolute Windows path in prefix. The prefix indicates the root directory for future installation and using such path allows us to correctly replace the mono installation with the newly built.

The process is a bit long and should exit correctly (without error messages).

Now type


This process is really long (up to 2 hours) and may crash. On my machine it consequently throws the 'mono incorrect operation' error. The good news is that make process doesn't try to recompile already compiled code on the next runs.

So if you got such error, just close the error message and repeat the make operation until it exits correctly.

Wonderful, mono is built (it took me 2 days to investigate all these underwater stones).

And finally type

make install

Now all created files are copied to prefix, which is our mono installation directory.

After this type mono -–version and check that it corresponds to the one you've downloaded. Also the word 'tarball' will be present after the version number.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Eugene Mirotin (Guard)
Software Developer
Belarus Belarus
No Biography provided

You may also be interested in...


Comments and Discussions

Discussions posted for the Published version of this article. Posting a message here will take you to the publicly available article in order to continue your conversation in public.
GeneralMy vote of 5 Pin
Look8721-Mar-12 19:05
memberLook8721-Mar-12 19:05 
GeneralNow how about OpenVMS... Pin
PIEBALDconsult15-Oct-08 13:11
memberPIEBALDconsult15-Oct-08 13:11 
GeneralCode Differences Pin
Jon-Hawkins12-Jul-07 2:40
memberJon-Hawkins12-Jul-07 2:40 
GeneralRe: Code Differences Pin
Eugene Mirotin (Guard)12-Jul-07 3:09
memberEugene Mirotin (Guard)12-Jul-07 3:09 
GeneralRe: Code Differences Pin
Jon-Hawkins12-Jul-07 4:19
memberJon-Hawkins12-Jul-07 4:19 
GeneralRe: Code Differences Pin
cfrankert12-Jul-07 5:29
membercfrankert12-Jul-07 5:29 
GeneralRe: Code Differences Pin
melchizedek13-Jul-07 3:27
membermelchizedek13-Jul-07 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 12 Jul 2007
Article Copyright 2007 by Eugene Mirotin (Guard)
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid