LINUX


Tuesday 7 July 2015

How to Compile and Run C# .NET application on Ubuntu - mono

Mono is a software platform designed to allow developers to easily create cross platform applications. It is an open source implementation of Microsoft's .Net Framework based on the ECMA standards for C# and the Common Language Runtime.

There are several components that make up Mono:
C# Compiler - The C# compiler is feature complete for compiling C# 1.0 and 2.0 (ECMA), and also contains many of the C# 3.0 features.

Mono Runtime - The runtime implements the ECMA Common Language Infrastructure (CLI). The runtime provides a Just-in-Time (JIT) compiler, an Ahead-of-Time compiler (AOT), a library loader, the garbage collector, a threading system and interoperability functionality.

Base Class Library - The Mono platform provides a comprehensive set of classes that provide a solid foundation to build applications on. These classes are compatible with Microsoft's .Net Framework classes.

Mono Class Library - Mono also provides many classes that go above and beyond the Base Class Library provided by Microsoft. These provide additional functionality that are useful, especially in building Linux applications. Some examples are classes for Gtk+, Zip files, LDAP, OpenGL, Cairo, POSIX, etc.

Installing Mono:
Open up the terminal Application > Accessories > Terminal and type following command
sudo apt-get install mono-xsp2 mono-xsp2-base
Console Hello World
To test the most basic functionality available, copy the following code into a file called hello.cs.
#include<stdio.h>
main()
{
   printf("Hello World\n");
   printf("My First C Program\n");
}

To compile, use gmcs: gmcs hello.cs
Here compiler will create "hello.exe"

Now execute the hello.ext using command: mono hello.exe
The program should run and output:
Hello Mono World


No comments:

Post a Comment