Installing Mono to Slackware64 14.0

Home / Installing Mono to Slackware64 14.0

Installing Mono to Slackware64 14.0

December 5, 2015 | Article | No Comments

Mono is a software platform designed to allow developers to easily create cross platform application. Mono is open source .NET development framework which can be built on top of Windows, Linux, Mac, iOS, and android. Based on ECMA standards for C# and the Common Language Runtime.

In this article we will discuss about installation of Mono for Linux Slackware64 14.0. But actually this is generic instruction and you can do it on any Linux, even BSD or Solaris if you have appropriate tools.

For this article I will use:

  1. Slackware64 14.0
  2. Mono 3 latest
  3. Mono 2

The method we will use is installation from source using source code downloaded from Github. As you might see, in this process we also need mono 2. It might seems odd but for compilation mono 3,  mono 2 is required. That’s why we will have to install mono 2 at least until compilation.

Obtain the Materials

Prepare a directory for storing source code and also for build purpose. Let say ~/nestmono/

The source code for mono 3 can be obtain from their github. To download it, open terminal and invoke following commands:

git clone https://github.com/mono/mono.git

At this point we have a directory named mono

Like I said before, we need mono-2 to compile mono-3. You can download the binary from Mono’s official site. But official site doesn’t offer native installation for Slackware. As alternative, we can install mono using following link. Or use Mono to download previous version of mono on compilation time.

Compilation

First install mono-2. Assuming we have download mono-2 with package filename: mono-2.10.5-x86_64-1sl.txz. We do binary installation at this point.

installpkg mono-2.10.5-x86_64-1sl.txz

Now go to our build directory and head to mono subdirectory. In this article, Mono would be installed to /usr/local. If you want to change the location, replace /usr/local path with any path you wish. Do following on terminal:

./autogen.sh --prefix=/usr/local
make
make install

If you prefer not to download mono-2 by yourself and using mono-3 to download mono-2 before compilation, then after invoking autogen.sh and before make do following:

make get-monolite-latest
make EXTERNAL_MCS="${PWD}/mcs/class/lib/monolite/gmcs.exe"

The process might take some times. At this point you should be success on installing Mono. We now should have C# compiler and runtime library. You might also remove mono-2 if you want. To do so, go to where we store mono-2 package and do following (using assumption you install mono-2.10.5 like we did earlier):

removepkg mono-2.10.5-x86_64-1sl.txz

Let’s check if mono is properly installed. Create a C# source file and name it mono.cs (or anything you like). Write this to the source:

using System;

public class HelloWorld {
  static public void Main () {
    Console.WriteLine ("Xathrya said: Hello Mono!");
  }
}

To compile use gmcs. The compilation of mono.cs will produce mono.exe which can be run using mono:

gmcs mono.cs
mono mono.exe

If successful, you will see this text: Xathrya said: Hello Mono!

If gmcs is not recognized (mostly because your mono installation path is not on $PATH environment variable) you can do one of following: make a static link or include to $PATH.

For static linking you can use:

ln -s /bin/gmcs /usr/local/bin/gmcs

For Manual path inclusion you add this to your ~/.bashrc (if you use bash):

export PATH=$PATH:/bin/gmcs

Personally I like using static linking. But since I installed gmcs on /usr/local (which mono and gmcs is in /usr/local/bin) and /usr/local/bin is inside of $PATH, I don’t need to create symbolic linking or expand environment variable.

,

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial