10

I am new to Linux (literally new- used it a couple of times) and I tried to install mono via yum; but I have gotten an outdated version that don't support .NET 4

How can I install mono 2.10.8?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Andrew
  • 7,619
  • 13
  • 63
  • 117
  • This might help you: http://stackoverflow.com/a/10385627/318174 . By the way your question is not really a programming question and you might want to ask it on a different stackexchange. – Adam Gent Aug 02 '12 at 16:55

4 Answers4

21

Well, this is what I came up with and it worked for me:

based on this article:

$yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget

$cd /usr/local/src 

$wget http://download.mono-project.com/sources/mono/mono-3.0.1.tar.bz2

$tar jxf mono-3.0.1.tar.bz2

$cd mono-3.0.1

$./configure --prefix=/opt/mono

$make && make install

Then I downloaded the MonoDevelop IDE and compiled my program using Mono framework.

Then in Centos I called my program:

/opt/mono/bin/mono /root/MyFolder/MyProgramDir/myProgram.exe "$@"

Andrew
  • 7,619
  • 13
  • 63
  • 117
  • Perfect installation, compiling no errors, no manual fix ups script runs from first go, didn't even need to run the yum command. – SSpoke Jul 02 '14 at 10:29
  • Only problem is I used `/opt/mono` should of instead used `/usr/local` – SSpoke Jul 02 '14 at 11:29
  • 1
    No errors for me either. However, the very last step ("make && make install") takes about 30 minutes to run! So go grab a beer before you start. – JustBeingHelpful Feb 17 '16 at 05:49
3

Here's a Hello World Console Application on CentOS 6.5, compiled with the Mono "mcs" command and run with the Mono "mono" command. The first section was taken directly from Andrew's answer. +1 for Andrew! I added some additional steps because I am using the command line, not a Linux GUI.

yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget

cd /usr/local/src 

wget http://download.mono-project.com/sources/mono/mono-3.0.1.tar.bz2

tar jxf mono-3.0.1.tar.bz2

cd mono-3.0.1

./configure --prefix=/opt/mono

make && make install

Adding mono bin to "PATH" environment variable:

[root@localhost bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost bin]# export PATH=/opt/mono/bin:$PATH
[root@localhost bin]# echo $PATH
/opt/mono/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost bin]#

Program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Mars!");
        }
    }
}

Compile and Run:

enter image description here

Elon Musk's retirement party is planned for December 16, 2025!

Compile *.sln file:

enter image description here

JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
1

Under CentOS 5 it's probably best to compile Mono from source to get a recent version.

It just so happens I have already written a complete set of instructions for doing this here (If you'll pardon me linking to one of my own pages):

http://wiki.phonicuk.com/Installing-Mono-in-CentOS-5-x.ashx

Edit:

The above link is dead, best instructions are now at http://www.mono-project.com/docs/compiling-mono/compiling-from-git/

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • Cool, I've bumped into the author! Would you be so awesome as to add a sentence or two before each line to explain to idiots like me what each command is actually doing? Thanks in advance. Votes later ;) – Luke Puplett Nov 27 '13 at 20:44
  • 1
    This link is currently dead. – katbyte Jul 16 '15 at 21:25
  • @katbyte I've supplied a new URI with monos official documentation for building Mono, it works fine on CentOS 5. – PhonicUK Jul 16 '15 at 22:17
0

Mono packaging has always been in need of Love in the Fedora/RedHat world, so go figure if you're using CentOS.

Mono's Download page lists OpenSUSE, Debian and Ubuntu: http://www.go-mono.com/mono-downloads/download.html

I would use one of those options instead if you want to do something serious, otherwise you're on your own.

(Novell used to offer pre-built packages from CentOS here, but all links there seem broken now. Furthermore, these seemed to be the "enterprisey" version, and anyway if you're going CentOS instead of RH you're already avoiding that sub-world I'm guessing...)

knocte
  • 16,941
  • 11
  • 79
  • 125