Thursday, February 25, 2016

How to compile mono and run a C# code on CentOS

Goal:

How to compile mono from source code and use mono to build a C# code on CentOS.

Env:

CentOS 6.5

Solution:

1. Checkout Mono source code from github

Refer to http://www.mono-project.com/docs/compiling-mono/linux/
git clone git://github.com/mono/mono.git

2. Switch to a branch

cd mono
git checkout mono-4.3.2-branch

3. Build mono from source

./autogen.sh --prefix=/usr/local
make get-monolite-latest
make
make install

4. Create a sample C# code

# cat test.cs
using System;
class ExampleClass
{
    static void Main()
    {
        Console.WriteLine("Hello, world!");
    }
}

5. Compile C# code using mono and execute it.

mcs test.cs
mono test.exe

5 comments:

  1. bash: ./autogen.sh: No such file or directory
    giving this error in centos 6

    ReplyDelete

  2. İnternette oyun indirme siteleri arasında güvenilir olanlar oldukça nadirdir, bu nedenle dikkatli olmak önemlidir. Eğer güvenli ve hızlı bir şekilde oyun indirmek istiyorsanız, önerim https://oyun.indir.biz.tr adresini ziyaret etmenizdir. Bu site, kullanıcılarına çeşitli oyun seçenekleri sunarken aynı zamanda dosya güvenliğini de ön planda tutuyor. Böylece, herhangi bir virüs veya zararlı yazılım riski olmadan oyunlarınızı indirebilirsiniz. Güvenliğinizi ön planda tutarak en iyi deneyimi yaşamak için bu siteyi tercih edebilirsiniz.

    ReplyDelete