Monday, 18 June 2012

Playing with Mono on the Raspberry PI

Mono is a free and open source (FOSS) project to implement the (Microsoft) .NET framework including the C# compiler and Common Language Runtime. To install you need to get the Raspberry PI up to date with the command

apt-get update apt-get upgrade

I actually run the command twice as it gave some warnings and to run it again. Then to install Mono tun the command

apt-get install mono-complete

which will download and install Mono. Once done (it will take a while) create a directory and create a file (you need to learn how to use an editor like vi or nano) called test.cs with the following contents.

using System;  
namespace hello {
    public class HelloWorld {

       public static void Main()
       {
           Console.WriteLine("Hello, World!");
       }
    }
}

Run the following command to compile the file

mono-csc test.cs

If it works then it creates a file called test.exe. You can run it directly using

./test.exe

Or more correctly you should use

mono test.exe

No comments:

Post a Comment