Search:  
Gentoo Wiki

Mono

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

Contents

Introduction

What is Mono?
"Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell, the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications."
- www.mono-project.com

Preparing for Mono

Before we begin, let's determine all of our options.

emerge -av mono

This produces the following output: (This is subject to change in future releases of the mono port.)

Calculating dependencies... done!
[ebuild  N    ] dev-dotnet/libgdiplus-1.1.13.2  USE="gif jpeg png -tiff" 1,230 kB
[ebuild  N    ] dev-lang/mono-1.1.13.6  USE="X nptl" 17,790 kB

USE

According to the official Gentoo documentation (http://www.gentoo.org/dyn/use-index.xml):

XAdds support for X11
icuEnables support for IBM's Internationalization Components for Unicode
nptlEnables support for Native POSIX Threads Library, the new threading module (requires linux-2.6 or better usually)

If you have no knowledge of USE variables then I suggest you take a look at the official documentation on portage. (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1)

Emerging Mono

Once you are entirely satisfied with your USE flags, you should check what is going to be installed to make sure all is well, and confirm if it is correct.
emerge -av mono

(It took my system about fifteen minutes for the entire installation. )

What to do if you are running grsecurity

Mono cannot be installed if you are running grsecurity w/ PAX enabled, a simple fix to this is while emerging mono just execute the following script in another window; and with luck you will have mono installed shortly.

File: /usr/local/bin/mono-install
#!/bin/sh
while ((1)); do
sleep .1
paxctl -m /var/tmp/portage/dev-lang/mono-1.2.4/work/mono-1.2.4/mono/mini/mono 2>/dev/null
paxctl -m /var/tmp/portage/dev-lang/mono-1.2.5/work/mono-1.2.5/mono/mini/mono 2>/dev/null
paxctl -m /var/tmp/portage/dev-lang/mono-1.2.5-r1/work/mono-1.2.5/mono/mini/mono 2>/dev/null
paxctl -m /var/tmp/portage/dev-lang/mono-1.2.5.1-r1/work/mono-1.2.5.1/mono/mini/mono 2>/dev/null
paxctl -m /var/tmp/portage/dev-lang/mono-1.2.6-r1/work/mono-1.2.6/mono/mini/mono 2>/dev/null
done

If the above does not work, make sure you have paxctl installed ("emerge paxctl"), and that one of the above commands matches your mono version and portage temp path. One way to find these values is to run the emerge once and let it fail, then see the working path in the error messages.

Testing Mono

Navigate to a worthy testing folder and create a new file with the following contents. (~/test.cs is assumed.)

File: ~/test.cs
using System;
public class Test {
 public static void Main(string[] args) {
  Console.WriteLine("Hello World!");
 }
}

Then execute the following command: mcs ~/test.cs. The "Mono Compiler Suite" compiles the source and outputs an executable. (test.exe)

Time to test and see if everything is working! mono test.exe

If you see the line:

Hello World!

Then you have successfully installed Mono and are prepared to run .Net/Mono compiled applications.

Running Mono Applications

Then normal way to run a .net application is with the mono command, which invokes the .net runtime and executes the specified application, as shown in the previous section.

To execute non-native binary files, such as .net executables, directly as if they were regular programs, the Linux kernel supports something known as the "misc" binary format. With this option enabled in the kernel (CONFIG_BINFMT_MISC), it is possible to register a "class" of executables (in our case .net applications) and associate them with a "wrapper" program for execution (the mono command).

Once registered, .net applications can be executed just like any native Linux application. To run the example application from the previous section, you'd simply type ./test.exe

In Gentoo you can use the init script provided by dev-dotnet/pe-format.

# emerge -av dev-dotnet/pe-format
# /etc/init.d/pe-format start
# rc-update add pe-format default

For more information on how to set this up, see Registering .exe as non-native binaries on the Mono project website.

Where To Go From Here?

Retrieved from "http://www.gentoo-wiki.info/Mono"

Last modified: Mon, 08 Sep 2008 07:09:00 +0000 Hits: 9,867