s h a n a 's  h i d e o u t

hit me

em português, se faz favor...


Mono + Cygwin Installation and Compilation Tutorial

How to go there and back again while remaining reasonably[1] sane


This document is about configuring cygwin to compile Mono. It's not about compiling applications with Mono. You have been warned.


Welcome, welcome! If you're reading this, it's probably because you want to try your hand at compiling Mono on Windows, possibly with the idea of contributing to Mono. Good for you! It also might mean that you're trying to do it while keeping an handle on your sanity, at least long enough to actually *code* something. That's ok, been there, done that, got the tshirt and kicked the mailman.

Traditionally, compiling Mono on windows has never been easy. Cygwin is very brittle, dependencies are a pain, and it takes so long you end up running out of coffee before it's finished, which is always a bad sign. This tutorial is designed to overcome brittleness and pain, though it won't do much for lack of coffee. Two out of three ain't bad, anyway :p

Starting off

This is the order by which this tutorial assumes you are doing things. This is because it is assumed that the Mono sources are sitting under a cygwin path, which is kind of hard to assume if you don't install cygwin before checking out the Mono sources. So, order of business:

  • Install Mono for Windows
  • Install cygwin
  • Checkout Mono sources
  • Compile Mono

Installing Mono for Windows

So, let's start off, shall we?

The simplest way to compile Mono is to use an already working Mono and go from there. Kind of an egg-and-chicken thing. So the first thing we need to do is to download and install the latest Mono for Windows. It is available on the Project Mono website. Just download the latest release and run the installer. The tutorial assumes that you install it at c:\Mono- . Substitute accordingly.

Installing Cygwin

Installing Cygwin is a pretty easy affair, the hard part being exactly *what* to install in the myriads of options given to us by the cygwin setup. The setup presented here is a lean, mean configuration, with the bare minimum to compile Mono. If you have cygwin already installed, it might be worth it to install it again to a different directory so that you have a clean cygwin to work with. Alternatively, you could check that the packages that you have installed are not on the forbidden list below, in which case you'll need to uninstall them to compile Mono.

Installing Cygwin consists of running setup.exe, choosing where to install it to, and what packages you want to install. You can download the setup from the Cygwin website. For the rest of this tutorial, it is assumed that you have installed cygwin to c:\cygwin. Substitute accordingly.

When you get to the package selection, click on the View button on the top right corner, to get to the Full View. Here, select the following packages to install

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

These selections will automatically select other packages, which is good and proper(tm). At this point, do not install make or glib. Don't do it. Just say no. The make version that comes with cygwin does not handle dos-style paths in pc files well, and will cause "multiple target patterns" errors when compiling Mono. GLib is supplied as a part of the Mono for Windows bundle, so we'll use that.

A proper make version, v3.80, is available from the Mono website. Download it, and extract make.exe from usr/bin. Put it in c:\cygwin\bin.

Configuring Cygwin

Now that cygwin is installed, open the cygwin shell. It will create your home directory when you open it the first time, so as soon as that's done and you get a prompt, close the shell. Go to your newly created c:\cygwin\home\user, and edit the .bashrc file. Add the following lines to the end of the file:


That /cygdrive path is a folder that cygwin makes available for you to access your windows drives by using linux-style paths. cygdrive is the default name of this folder, so if you've customized this, substitute accordingly.

The Mono sources

To compile Mono you'll need, of course, the Mono sources. These can be obtained through anonymous SVN from svn.myrealbox.com. For this you'll need a subversion client, command-line or graphical. You can obtain a command-line Win32 version here, or the graphical TortoiseSVN client.

In case you're using a command-line version, you can obtain the mono sources by checking out two modules, mono and mcs:

svn co svn://svn.myrealbox.com/source/trunk/mono
svn co svn://svn.myrealbox.com/source/trunk/mcs

Create a mono folder under c:\cygwin\usr\src, and run these commands there. c:\cygwin\usr\src is equivalent to /usr/src in the cygwin shell, so by the end of this, you should have the following tree:

/ (c:\cygwin)


Now that everthing's ready to go, it's time to compile.

Open the cygwin shell, and go to /usr/src/mono/mono. There, type:

./autogen.sh --prefix=/usr/local
(go make some coffee, watch a movie. Compiling Mono can take between 45 minutes and 2 hours, depending on your machine)
make install

Testing your new Mono

Confirm that you are now running your new Mono by typing "which mono" at the shell prompt. It should give the /usr/local/bin path. Typing "mono" will give you a usage message. Now you can play with your minty fresh Mono!

If you run into problems

The compilation process outputs a lot of information. It is useful to catch it to a logfile in case you run into problems, so if it gives you an error, run make again like this: make>log 2>&1
This will output all messages and errors into a file called log, so you can look at the errors easily.

Here is a list of a few things that can go wrong when you're compiling or installing.

The compilation stops in the monoburg folder, with an Error 53.

Try using dos-style paths to point to c:/Mono- in your .basrc file, instead of /cygdrive/c/Mono- . You'll have to exit the shell and change .bashrc so that it will use the new paths when you go back to the shell.

The make install stops when trying to run the mkinstalldir script, or another shell script, reporting several command not found errors and complaining about not understanding shell commands

You've hit the dos-style return/linefeed problem. You'll have to convert the offending shell script from dos-style line breaks to unix-style line breaks. If you have Ultra-Edit installed, or another editor that understands unix-style regular expressions for search-and-replace, open the shell script and do a search-and-replace, replacing \r\n for \n. There are other tools that do conversions, google is your friend. Save the file and run make install again.

If you need help, you can login to irc.gnome.org and go to the #mono channel, and ask for help there. I'm usually there as shana. You can also post a message to the mono mailing list.


  1. Install the latest Mono for Windows (currently version, http://www.mono-project.com/Downloads).
  2. Install cygwin, selecting the following extra packages:


    Do *not* install make and do *not* install glib2.

  3. Put this here make v3.80 in your cygwin bin. Just the make.exe is enough.
  4. Open the cygwin shell.
  5. Exit the cygwin shell.
  6. Go to the newly created /home/whatever, and edit .bashrc, adding these lines to the end:


  7. Create a mono folder under c:\cygwin\usr\src, and checkout the mono and mcs modules from svn there, so you have the following tree:

    / (c:\cygwin)

  8. Open the cywgin shell.
  9. Type "mono". You should get a usage message, indicating you're using the one you installed. Cool.
  10. Go to /usr/src/mono/mono, type:

    autogen.sh --prefix=/usr/local
    (wait an hour or two, make some coffee, watch a movie, etc)
    make install

  11. Rejoice


[1]Warning: reasonability measurement might differ from individual to individual. Symptoms might include rash, jerkiness of movements, desire to scream uncontrollably, loss of pun control resulting in bad joke syndrome. When in doubt, go nuts. I know I do.

[home] [programming] [cats] [tarot] [books] [rants] [links] [hit me]