Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

An Introduction to Mono Development : Page 2

Microsoft's .NET Framework CLI implementation isn't the only CLI development game in town. The Mono project is both surprisingly mature, and surprisingly compatible—and you can deliver applications built on it to multiple platforms, including Windows.


advertisement
The Mainstream CLI Distributions
To date, there are two mainstream implementations of the CLI, beyond Microsoft's CLR and .NET Compact Framework (see Table 2).

Table 2: Here are two important CLR implementations in addition to Microsoft's.
CLI Distribution Web Site Meaning in Life
Mono www.mono-project.com Mono (a Spanish word for Monkey, as in 'code monkey') is an open source and commercially supported distribution of .NET sponsored by Novell Corporation. Mono is targeted to run on many popular flavors of Unix/Linux, Mac OS X, Solaris, and Windows.
Portable .NET www.dotgnu.org Portable .NET is distributed under the GNU General Public License. As the name implies, Portable .NET intends to function on as many operating systems and architectures as possible, including many esoteric platforms such as BeOS, AIX, Xbox, and Sony PlayStation 2 (no, I'm not kidding about those last two).

Each of the CLI implementations shown in Table 2 provides a fully functionally C# compiler, numerous command line development tools, a Global Assembly Cache (GAC), sample code, a local documentation system, and dozens of assemblies that constitute the base class libraries.

Beyond implementing the core libraries defined by Partition IV of ECMA-335, Mono and Portable .NET provide MS-compatible implementations of mscorlib.dll, System.Data.dll, System.Web.dll, System.Drawing.dll and System.Windows.Forms.dll (among many others). In addition, the Mono distribution defines a handful of assemblies specifically targeted at Unix/Linux and Mac OS X operating systems. With this minimal background in mind, you're ready to install Mono itself.

Obtaining and Installing Mono
First, download the Mono installer for Microsoft Windows. When the download is complete, double click the executable to begin the installation process, accepting each of the default settings.

 
Figure 1. The Mono Directory Structure: Here's what directory structure looks like after you first install Mono.
Author's Note: Installing Mono will not interfere whatsoever with any existing installation of Microsoft .NET or the Visual Studio IDE.

Examining Mono's Directory Structure
By default, Mono installs under C:\Program Files\Mono-<version> (at the time of this article, the latest and greatest version of Mono is 1.1.15). Beneath that root you will find a number of subdirectories (etc, contrib, man, share) that may appear to be strangely named unless you have a background in Unix\Linux development (see Figure 1).

In this article, you need only concern yourselves with the following subdirectories:

  • Bin—Contains a majority of the Mono development tools including the C# command line compilers.
  • lib\mono\gac—The location of Mono's Global Assembly Cache (GAC).
Given that you run the vast majority of the Mono development tools from the command line, feel free to add the \bin folder path to your Path environment variable to simplify using the command-line tools.

 
Figure 2. Mono Runtime Environment: The figure shows details of the Mono runtime environment.
As a shortcut however, you may make use of the Mono command prompt which automatically recognizes each of the command line development tools. You can activate this console via the "Start | All Programs | Mono For Windows" menu option. To test your installation, enter the following command and press the Enter key:

mono --version

If all is well, you should see various details regarding the Mono runtime environment (see Figure 2).

The Mono Managed Compilers
Similar to the Microsoft's CLR distribution, Mono ships with a number of managed compilers:

  • mcs.exe / gmcs.exe—The C# compilers
  • mbas.exe: The Mono BASIC compiler
  • booc.exe: The Boo language compiler
  • Ilasm.exe / ilasm2.exe: The Mono CIL compilers
While this article focuses only on the C# compilers, it is worth pointing out the role of the remaining members. Mbas.exe, the BASIC compiler for the Mono project, is a superset of the Visual Basic .NET programming language. While this tool is currently under development, the intended goal is to bring the world of humanly-readable keywords (Inherits, MustOverride, Implements, et. al.) to the world of Unix/Linux and Mac OS X (see the MonoBasic project for more detail).

Boo is a new object-oriented statically-typed programming language for the CLI that sports a Python-based syntax. Check out http://boo.codehaus.org for more details on the Boo programming language. Finally, as you might have guessed, ilasm.exe and ilasm2.exe are the Mono CIL compilers (the second of which supports .NET 2.0 language constructs).

Working with the C# Compilers
Mcs.exe was the first C# compiler for the Mono project, and it's fully compatible with C# 1.1 (in fact, mcs.exe is written in C#). Like the Microsoft C# command-line compiler (csc.exe) mcs.exe supports response files, a /target: flag (to define the assembly type), an /out: flag (to define the name of the compiled assembly), and a /reference: flag (to update the manifest of the current assembly with external dependencies). You can view all the options of mcs.exe using the following command.

mcs -?

Gmcs.exe (generic mcs.exe), as the name implies, is a version of mcs.exe that has support for .NET 2.0 specific C# language features (generics, covariance/contravariance, nullable types, partial types, etc) and references the .NET 2.0-based base class libraries. The command line options of gmcs.exe are identical to mcs.exe, which you can verify with the following command:



gmcs -?

Given the presence of two C# compilers, you might naturally assume that only gmcs.exe can be used to build .NET applications that make use of the C# 2.0 language enhancements. In reality, mcs.exe is the first of the two compilers to support 2.0 features, which are then perfected and ported to gmcs.exe.

The difference is that mcs.exe automatically references the .NET 1.1-based base class libraries, while gmcs.exe always references the .NET 2.0-based base class libraries. Given this, gmcs.exe will become the default compiler in a future Mono release leaving mcs.exe in the dust as a historical footnote.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap