Building Mono on Windows
Pages: 1, 2
3. Completing the Build
The last phase of the build process will require you to obtain a copy of the Mono source code. The recommended way to accomplish this is by using anonymous Subversion checkout. The Mono project uses Subversion as its source code management tool. In order to use Subversion, you first need to have a Subversion client installed on your machine. Finally, once you have Subversion installed, and you have checked out and exported the Mono source code, then you can complete the build steps.
3.1 Installing Subversion
If you already have the Subversion, then you can skip this section. You will need to obtain the the Windows installer with the basic Subversion Win32 binaries. You can obtain the installer from the Tigris.org documents and files area.
- Run the setup routine from the the directory chosen during the setup download.
- Click the Yes button to proceed with the installation.
- Click the Next button to begin the installation.
- Select "I accept the agreement" and click the Next button.
- Click the Next button again, and the installation wizard will request the Subversion install location.
- Accept the default, C:\Program Files\Subversion, by clicking the Next button. The installation wizard will then request the start menu folder.
- Accept the default, Subversion, and click the Next button. The installation wizard will then request whether you want to install desktop and Quick Launch icons.
- Make your desired selections for shortcut icons and click Next to finalize the installation wizard selections.
- Finally, on the "Ready to Install" screen, click the Install button to begin the installation. You will receive an information screen after the installation is complete.
- Click Next and then Finish to complete the installation. The installation wizard should ask if you want to restart your system. Click Yes to restart your system.
When your system restarts, you should verify that the Tortoise Subversion Windows Explorer plugin was successfully installed. From within Explorer, right-click on any directory. You should see a new menu item: TortoiseSVN. Click on this entry and you should see another menu list. Select the About menu option. You should receive the TortoiseSVN 1.1.1, Build 1857 about dialog box.
3.2 Check Out the Mono Source Code
In order to build Mono, you will need to
check out three source subtrees: mono, mcs, and libgdiplus. To anonymously check out
the Mono source code:
- First, create a directory as a sandbox to check out the source code files. I suggest C:\monosvn\mono\x.x, where x.x should represent the version of the source code.
- From within Windows Explorer, locate the sandbox directory you created in the previous step and right-click on the directory.
- You should have two TortoiseSVN menu options. Select the Checkout option.
- The Subversion Checkout dialog will appear. In order to access the Mono Project source code, you need to point the Subversion client to the Mono Project Subversion repository. In the URL for repository enter "svn://svn.myrealbox.com/source/trunk/mono".
- Ensure that
your sandbox directory is identified in the checkout directory, and
click Ok.
Note: When the checkout is complete, the subtree will appear in the sandbox directory in explorer. The directory icon will appear with a little check in the lower left-hand corner. This illustrates that the directory was checked out from Subversion. - You need to export the directory into your Cygwin directory structure. Right-click on the c:\monosvn\mono\1.2 directory. On the context menu, select TortoiseSVN and then export. Subversion will provide the Browse For Folder dialog window.
- Select C:\cygwin\download\mono-1.1.4 and then click Ok. This will copy the files from the sandbox to the build directory.
- Repeat
the checkout and export steps for the
mcsandlibgdiplussubtrees. In the checkout step, substitute the subtree at the end of the repository URL, for example: "svn://svn.myrealbox.com/source/trunk/mcs".
3.3 Build Setup
You are now almost ready to begin the build process. You first need to take care of few preparatory steps and then you'll be ready for the build. These fews steps will redirect the calls for the C# compiler to the Mono C# compiler, allowing you to build Mono with Mono. To finish our preparations, complete the following:
- From within
the Cygwin environment, type
mkdir -p /opt/monoand pressEnter. - You now need
to mount, within the Cygwin environment, the root directory you used for
the Mono combined installation. Enter
mount -s c:/mono/Mono-1.1.3 /usr/localand pressEnter. - Next, you need
to create two symbolic links. First type
ln -s /usr/local/bin/mcs ./csc.exeand pressEnter. This will substitute the Mono C# compiler for the C# compiler. You can test this by typingcsc.exe --version. You should receive the result shown in Figure 4.
Figure 4. Checking the CSC version
- Next you need to type
ln -s /usr/local/bin/monoresgen.exe ./resgen.exeand pressEnter. This will substitute the Mono Resource File Generator for the .NET Framework Resource File Generator. Confirm this by typingresgen.exe. You should receive the result shown in Figure 5.
Figure 5. Generating the resources
3.4 Building Mono With Mono
Finally,
you are ready to build Mono with
Mono. From the mono subdirectory, you will complete the three-step
build process involving autogen, make, and make install. To finish the
process:
- From within the Cygwin environment, type
cd /download/mono-1.1.4/monoand pressEnter. This will put you in the Mono directory of the source code. - Type
./autogen.sh --prefix=/opt/mono --with-preview=yesand pressEnter. Ifautogenencounters any problems with the environment or in terms of dependencies, it will stop. If the process does not halt, you should receive a long stream of console comments; at the end, however, it should resemble Figure 6.
- Type
makeand pressEnter. Themakecommand will take a few minutes, so please be patient. Also, just as with theautogencommand, themakecommand will produce a long stream of console comments. What you should be alert for is any type of error message that appears immediately before themakecommand completes. The output should look like Figure 7.
Figure 7. Making Mono
- Type
make installand pressEnter. Once again, this will take a few minutes. A successfulmake installshould look like Figure 8.
4. Post-Build Instructions
Now that you have successfully built Mono, you now have a directory structure in /opt/mono that is similar to the one that the Mono Combined installer creates for Win32. Keep in mind that the resulting output does not include GTK+, Gtk#, MonoDoc, or XSP. Also missing are prerequisites that almost never change and that originate from other parties like Microsoft (as in the case for msvcr71.dll, found in C:\mono\Mono-1.1.3\bin). However, you now have the essence of the latest Mono release. Your options at this point include repackaging all of the framework and its supporting components or just using a particular library or executable that you know was just fixed in SVN.
To verify the results of the build process,
change to the prefix directory, /opt/mono, and study its
contents and structure. There are two significant kinds of files
created in the directory hierarchy. There are binary files like
/opt/mono/lib/mono/1.0/mcs.exe and /opt/mono/lib/mono/1.0/System.Xml.dll.
These are examples of managed
assemblies. Other resulting binary files include unmanaged
executables and static libraries such as /opt/mono/bin/monodis.exe and
/opt/mono/lib/libmono.a.
The build process also creates many
configuration and/or supporting files that might contain file PATH
information that is specific to the choices made when autogen.sh was
run for the first time (remember ./autogen.sh --prefix=/opt/mono
--with-preview=yes? Refer to 3.4, "Building Mono With Mono").
Examples of these files are /opt/mono/lib/pkgconfig/mono.pc and
/opt/mono/bin/ilasm. These are generic text files, so you can
edit
their contents with any ASCII-friendly text editor. Changing these
files is a critical function of the Windows Combined Installer, as you
will now see.
In theory, you could take all of the child
directories that are found in /opt/mono and simply copy and paste
them over to C:\mono\Mono-1.1.3. Unfortunately, the text
files
that I mentioned above contain an unusable path reference to /opt/mono.
The Windows operating system would not be able to resolve this path, and
your Mono installation would not work. Remember, that path is only
viable in the Cygwin environment, which is not required to run the
resulting Mono in Win32. You would also be missing some batch
files that parallel the shell scripts. The batch files are
the
ones that actually invoke the execution of the Mono runtime
(C:\mono\Mono-1.1.3\bin\mono.bat) and indispensable tools like gacutil
(C:\mono\Mono-1.1.3\bin\gacutil.bat) while in Windows. In fact, if you
were to look at the Inno
Setup installer script that was
used to
generate mono-1.1.3-gtksharp-1.9.1-win32-0.4.exe, you will notice that
the largest portion of the script goes to
searching and replacing a constant, C:\Target, by the path that the
user selects during the installation routine.
5. Call to Action
Today, building and deploying Mono on the Win32 platform without the Win32 Mono Combined installer requires extensive manual intervention. This must change. The Linux Mono community enjoys great autonomy with the Linux build process. As I have described, it is clear that the Windows Mono community does not share that same autonomy. I understand that this is partially because Mono originates from a Linux-friendly environment. However, I'm sure that the same spirit of innovation and ingenuity that has distinguished the Mono project thus far, can also help resolve this disparity. Therefore, I urge the Mono community and especially the core Mono team to provide the necessary guidance, resources, and focus to help automate the Windows build and deployment process. I'm sure that if we accomplish this goal, we will unleash significant pent-up demand for the Mono project from the Windows C# community. And if there's anything I've learned about open source software, is that it is all about the community, and the bigger the community the better.
Appreciation
As has been the case for me so many times before, this effort would not be possible without the determination and drive of my good friend Francisco (Paco) Martinez. Through countless hours and cups of coffee, he perfected this process and then made it seem simple as we went through it step by step. Eric Raymond once said that you're not a hacker until someone calls you one, so I'm here to say: "Paco is a hacker extraordinaire." With the continued support of O'Reilly Network, we look forward to sharing many other articles focusing on Mono for Windows geeks.
Kevin Shockey is an emerging high technology entrepreneur.
Return to ONDotnet.com.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 6 of 6.
-
resgen.exe
2005-02-14 21:53:18 Harinath [Reply | View]
I think you can remove the section on creating a resgen.exe. I have fixed it in the Mono SVN tree. -
resgen.exe
2005-08-02 00:31:18 huaiyang [Reply | View]
I can generate the resource file from the following .resx. Do you know why? Many thanks for your help.
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used forserialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Organisation.ico" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKhJREFUOE+tUwEO
wBAMnJ97mp91Ws4uVWbJJI26cK6n0jUPCTAPpd0eyTkriZRSLDRXDKHrLQEOM9EXErvV33iqZMiGfD9D
SS9jKsXqPQmU570w6SKNpOV1VXPGUGJk5j8EKIEVMLZVYJr7YC+AKemWYGXgG8HjvNnVjGvW9by/TtSN
ktXxRdhrUKCh+Plsg98YYdFhJRofx9dPB7i55n+EruL+j7DoB96Qo2TotJk48AAAAABJRU5ErkJggg==
</value>
</data>
<data name="CAMERA2.ico" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAJhJREFUOE+lUgsO
gCAI9egezZsRL8EhYmGxsTaS99NSuFprhO+folpr2Aw65pZoItVlDH3jn848iVW8VaAAkcLJsmUCo13I
KCiWyfreZYP5okCGr2Eq6ARgZUOBb78UXr3PQQ6dvRENjKgQevGafG0jB7GSXJNjYEV9siAY7BvXdF/V
WQYdQJcHSN5CD43jE5DjEKNn/ER/AdA2NQj53bN3AAAAAElFTkSuQmCC
</value>
</data>
<data name="buDiary.Icon" type="System.Drawing.Icon, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAIAICAQAAAAAADoAgAAJgAAABAQEAAAAAAAKAEAAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAAAIAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/
AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+PAAAA
AAAAAAAAAAAAAAD4+PgAAAAAAAAAAAAAAAAAj4+PCwAAAAAAAAAAAAAAAPj4+AuwAAAAAAAAAAAAAAAP
gAALuwAAAAAAAAAAAAAACPC7sLuwAAAAAAAAAAAAAACAu7sLuwAAAAAAAAAAAAAAALu7sLuwAAAAAAAA
AAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuw
AAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAA
sLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLuwAAAAAAAAAAAAAAsLu7sLsAAAAAAA
AAAAAAAAsLu7sLBwAAAAAAAAAAAAAAsLu7sHcAAAAAAAAAAAAAAAsLuwd3CAAAAAAAAAAAAAAAsLB3cI
iAAAAAAAAAAAAAAAAHdwiIiAAAAAAAAAAAAAAAd3CIiIgAAAAAAAAAAAAAAAAIiIiIAAAAAAAAAAAAAA
AAiIiIgAAAAAAAAAAAAAAAAAiIiAAAAAAAAAAAAAAAAAAAiIAAAAAAAAAAAAAAAAAAAAAAAAH////wP/
//8A////gD///4Af//+AD///wAf//8AD///AAf//4AD///AAf//4AD///AAf//4AD///AAf//4AD///A
Af//4AD///AAf//4AD///AAf//4AD///AAf//4AD///AAf//4AD///AA///4AP///AH///4D////B///
/48oAAAAEAAAACAAAAABAAQAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAA
AACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAB3AAAAAA
AAAIiAAAAAAAAAAACwAAAAAAALewsAAAAAAAC3sLAAAAAAAAt7CwAAAAAAALewsAAAAAAAC3sLAAAAAA
AAt7CwAAAAAAALewAAAAAAAAC3B3AAAAAAAAB3CAAAAAAAAHCIAAAAAAAACIAAAAAAAAAAAAH/8AAA//
AAAD/wAAgf8AAID/AADAfwAA4D8AAPAfAAD4DwAA/AcAAP4DAAD/AQAA/4AAAP/AAAD/4AAA//EAAA==
</value>
</data>
</root>
-
msys?
2005-02-08 05:24:07 simon_massey [Reply | View]
msys is a minimal cygwin environment from the MinGW ('Minimal Gnu Windows') project. the idea behind msys it is that wont want to install the whole of cygwin just to run the latest gcc compiler and friends on windows. it would appear that a lot could be learnt from the mingw to get mono to build on cleanly on windows ("MinMW"? - Minimal Mono for Windows?). Perhaps a starting point might be to install msys and then add the required cygin packages to the baseline install.
-
TortoiseSVN Link
2005-02-08 04:16:52 Paco_ [Reply | View]
The article points the user to obtain Subversion for Windows but later gives instructions on using TortoiseSVN. That is not to say that you can not very well complete your tasks with the download that Mr. Shockey points you to. However, here is a link to get the software package referred to on the instructions.
TortoiseSVN







