The cool thing about the Raspberry Pi is that it is really really cheap and really really popular.
Until recently the worst thing about the Raspberry Pi has been the lack of hardfp version of Mono, leaving us .NET developers with 2 options:
- Learn something new (like Scala)
- Run the softfp Mono on the older Debian Squeezy Linux Distro
Now I know C# developers will be balking at the idea of #1, which only leaves #2.
Now Mono supports hardfp and a recent Mono (3.2.7), which is Good News(tm) as that means it supports the sgen GC as we’ll has the hardware floating point extensions on the ARM6 on the Pi.
Instructions are available here, but I hit a couple of small wrinkles on a fresh Raspbian install, so for my benefit and yours:
Step by Step
A couple of people have commented about how they needed to sudo some of these things (I didn’t need to – don’t know why), but remember, when in doubt sudo
- Ensure you have 2GB+ free on your SD card and a lot of time to spare
- Launch a terminal window/ssh into your Pi
- sudo apt-get update
- sudo apt-get install mono-complete
- sudo apt-get install automake
- sudo apt-get install libtool
- git clone git://github.com/mono/mono.git
- cd mono
- ./autogen.sh –prefix=/usr/local –enable-nls=no
- Note the above step reads two dashes before prefix and enable-nls. Thanks crazy fonts (and eagle eyed readers)
- sudo make
- Wait a long time (6 hours +)
- Ignore the errors and hope they don’t mean anything
- sudo make install
- Wait some more
- Ignore the errors and hope they don’t mean anything
- PROFIT!
Now type mono –version and hopefully see this:
pi@raspberrypi ~/mono $ mono --version Mono Runtime Engine version 3.2.7 (master/e94da6d Tue Dec 10 00:31:36 UTC 2013) Copyright (C) 2002-2013 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: normal Notifications: epoll Architecture: armel,vfp+hard Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen
For directions on how to be able to build and run Winforms apps see this excellent post here
Thanks a lot for your guide.
on step 9
maybe need ? else I got errors
Thanks a lot for your guide.
on step 9 [./autogen.sh –prefix=/usr/local –enable-nls=no]
maybe need [./autogen.sh –enable-nls=no] ? else I got errors
Thank you for the guide but just to add – on step 9 it appears as “-” however I believe this is meant to be “–” instead.
Thought as much, it is the font of the blog, ” – – ” two dashes, not one!
I’ll add something to the body to make it more obvious – thanks!
i had to do sudo make install
I’ve updated instructions to sudo all the things!
Winform apps did not work after the install because it could not find libgdiplus had to perform the following from the mono folder
git clone git://github.com/mono/libgdiplus
cd libgdiplus
./autogen.sh –prefix=/usr/local
sudo make
sudo make install
After all of that about 1 hour winform apps work fine.
Awesome thanks for the addition. I’ve only used for CLI apps as I’m just using ssh to he pi, but I’ll be sure to add a link in the article to your comment 😉
Any chance that you or someone else who already did the compilation provide the binaries so that not everyone who wants a non-broken mono version has to go through the compile grind? Would be very thankful.
Thanks for the guide! Seems like it only works with an en-us UTF8 locale, though.
After I switched to en-us UTF8 and rebooted the pi, everything compiled.
Now installing and testing 🙂
What a PITA.
After
sudo make install
now a simple WinForms “HelloWorld.exe” exits with an exception stating that libgdiplus.so cannot be found. I’m giving up. Hopefully someone soon will come up with something I simply can sudo apt-get install …
While I completely agree its not ideal that theres not an out-of-box solution yet, it *does* feel like the point of the pi is to enable this kind of “tactile” play. I’ve built more open source solutions on my pi than on my Windows or Mac boxes, and theres a definite feeling of achievement when it works. But sometimes you *really* have to work to get that feeling!
@thedo666: I beg to differ. Because that notion would imply that you think releasing a *completely broken, non-working (as in: calculates things wrong) mono version on the repository* (2.10.XX) without any mention of its state was also with the intention of nurturing someone’s sense of accomplishment once you discover that state and take steps to remedy it.
The sort of “tactile play” as you call it always should be *optional*, and never mandatory (as in the case of the mono binaries).
I absolutely agree that its a massive fail that the “out-of-box” solution isn’t just damaged but entirely broken. It plain and simply shouldn’t be there until its working and stable.
I did state at the top of the post that there were 2 options until now:
Learn something new (like Scala)
Run the softfp Mono on the older Debian Squeezy Linux Distro
It sounds like you don’t want to do option 1, you don’t want to build it (which I guess counts as option 3), so that leaves option 2.
had no problem getting this to work on Raspbian but always got a disk error proc/sys/kernel/hung_task_timeout_secs scsi_eh_0 when I tried Arch Linux from the raspberry site. Disk error always occurred during the make at the same place. Gave up after three days and when back to Raspbian
Pingback: MonoGame บน Raspberry Pi (ภาคทดลอง) | Raspberry Pi Thailand
I am successful in getting the package installed. confirmed by mono -V
However it does not create the mod_mono.conf file that is needed for the Apache2.conf file.
I checked the entire raspi and can not find this file anyplace.
What can I do?
Tom: did you ever figure out how to get mod_mono?
I used no-no utf8, should that matter?
Having some problems with mscorlib.dll not found in mono/2.0, but can see it is present in mono/4.0. Tried numerous ways to override runtime, but it seems to default to 2.0.50727 for some reason?
Cant say for sure as it defaulted to the correct runtime for me after I built it, so I gather the defaults for encoding in the default UK locale.
Looking at Markus reply it has to be en-US, but I havent had any reason to rebuild in other locales.
After compiling are there files that can be deleted? like the sources or something like that?
BTW when will this version be put in the apt repository? it would be great not to compile the entire library. Thanks in advance
All the instructions after #6 are unnecessary. All I did was install the Mono Debian packages according to instructions 1-6, and then I got this:
mono –version
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. http://www.mono-project.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: armel,vfp+hard
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
Didn’t have to compile anything, so it looks like the currently available packages have everything needed.
Thanks for this, however as Marquis de Sadé pointed out, you don’t need to recompile Mono on Raspbian anymore – the hard float package is supported now via just “sudo apt-get install mono-complete”. You don’t even need 2GB+ free space – it takes up less than 200mb. I used the offical raspbian image from 2014-06-20.
Here’s a test application to check if hard float is working or not …
// mono test app
// compile: dmcs HelloWorld.cs
// run: mono HelloWorld.exe
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
// The correct answer to this is 1.
// If it outputs 0 then its running Raspbian (ARM hard float) and is broken…
// Run the Debian Wheezy (soft float) distro instead.
Console.WriteLine(“Floor(1.5): ” + System.Math.Floor(1.5));
}
}
Thanks for this simple test. In case any other noobs try to copy & paste this code onto the raspberry pi, the quotes in “Floor(1.5): ” have to be straight quotes, not angled quotes. Execute this with: mcs float-test.cs
Wait for it to compile, then execute: mono float-test.exe
For fellow Arch Linux users on Raspberry Pi, it fixed it when I ran the following configure statement:
./configure –prefix=/usr/mono –with-libgdiplus=installed –with-moonlight=no
http://mono.1490590.n4.nabble.com/The-assembly-mscorlib-dll-was-not-found-or-could-not-be-loaded-td3165401.html
Also, for some reason the version of mono I had from “pacman -S mono” was not in the path, so I had to make sure I was using v3.4x when I typed “mono -V”. I could have changed the path or what I did, since the version of Mono that was in the path was worthless, I just moved both mono and gmcs to the path so those were called.
Pingback: What can C# be used for? - Marketing & PR - Infragistics.com Blog
Pingback: Mono su Arietta | hthings
Thanks for posting this, it has helped me out when testing out vNext on a Raspberry Pi. As others have said, a full compile is no longer necessary, however, it is if you want to run vNext, because it relies on mono 3.4.1 or later.
you need cmake for later builds of mono. So, you could add this:
6.5. sudo apt-get install cmake