The linux operating system installs MONO to perform the detailed steps for the C program

  • 2020-05-26 10:03:19
  • OfStack

Step 1 environment (under UBUNTU system)

sudo apt-get install mono-gmcs mono

Step 2 establish example.cs

class X {
static void Main () {
System.Console.Write("My first mono app worked!/n") ; 

Step 3: compile

gmcs example.cs

Step 4


Use C# in Linux (on Fedora system)

When Microsoft launched its.NET strategy, one of the goals was to make the software run on many different platforms.

Mono, an open source project, enables.NET to run on your Linux operating system.

If, like me, you work with Microsoft and like Linux, this Mono will help you and me. You can write C# programs on both platforms.

Download the latest installation of Mono from I took a look at the latest Stable version of Mono on the official website at the time of writing this article.

Before installing Mono, you must make sure that you have GIMP Toolkit, Drawing Kit and pkg-config. You can download them at It is recommended to download the latest version. If you already have these on Linux, you may need to upgrade them as well.

Install the software below:

# rpm -Uvh glib2-2.0.0-1.i386.rpm
# rpm -Uvh glib2-devel-2.0.0-1.i386.rpm
# rpm -Uvh pkgconfig-0.12.0-1.i386.rpm

The next step is to unzip Mono:

# tar -zxvf mono-

The following:

# ./configure
# make
# make install

When all is said and done, your Linux system will have a working Mono, which includes Mono's C# compiler, Mono's just-in-time compiler, and mint(The Mono interpreter). Now you can write C#. For example, hey hey, write the most famous Hellow World program:

class Hello {
static void Main() {
System.Console.WriteLine("Hello World") ; 

Oh, it is a classic. The C# program must have the suffix.cs. Enter the program and save it, say as HelloWorld.cs and then compile it:

# mcs Hello.cs

If you write the program correctly, this command will generate an MSIL file called HelloWorld.exe, which you can then use:

# mint HelloWorld.exe
Hello World

mint interprter has a number of commands to choose from, including --trace and --debug, which are useful for debugging. When your program is complete, you can compile on the JIT compiler:

class X {
static void Main () {
System.Console.Write("My first mono app worked!/n") ; 

The common language runtime provides cross-platform capabilities. The.NET program runs on any system on which CLR is installed. In fact, Mono's C# compiler was compiled on the Windows platform using Microsoft.NET Framework SDK and then moved to the Linux platform. You can transfer the program compiled on Windows to Linux and run it.

Mono is not fully implemented yet.NET Framework, but it's enough to get you to run the program you want to write. Open source things are evolving fast, and may soon be able to meet all your needs.

By the way, there is an Gtk# project on, which is dedicated to binding gtk+ toolkit to the C# language. It also aims to provide Mono libraries that are compatible with Windows.Forms. Of course, moving from Windows to Linux is difficult after all, so let's keep an eye on its progress.

Related articles: