Over the past weeks I struggled to get a working Mono installation without success.
I have tried it on Debian6_x64
, Debian7_x64
and Ubuntu_12.04_x64
.
I have installed it using the default mono-complete using apt-get
, tried compiling it from GitHub and from alternative repositories. Either with Mono 2.x or 3.x, I followed several tutorials and nothing seems to work.
Unfortunately I don't have the error logs of past installs but at this moment my current situation is:
Ubuntu 12.04 x64
Mono JIT compiler version 3.4.0 (master/250756b Sun Mar 2 15:02:07 EST 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
I'm trying to run a c# program I compiled under windows and the error I get currently is:
user@host:/home/pck# mono Program.exe
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/local/lib/mono/4.5/mscorlib.dll' directory.
I've been googling and nothing seems to work. I'd greatly appreciate any advice that could help.
Thanks!
The best thing to do nowadays is install Ubuntu Trusty 14.04 (LTS), which includes mono 3.2.8 in its default repositories (easy to install through apt-get).
It's not automatically granted that a C# application developed under Windows will work under Linux, using Mono libraries.
This depends on:
- The libraries used to develop the application under Windows. As far as I know, for example, the libraries used in WPF have no compatibility in Mono. Have a look at this page to check the compatibility of your application.
- The version of Mono installed. Each version introduces fixes, enhancements and support for new libraries. This means that your program will not work without any problem and you could encounter some errors.
About your issue, it seems that your application expects to find the libraries related to .NET Framework 4.5, but they're not installed. Install the correct version that supports them. Make sure your application doesn't use specific features of Windows platform. In that case, you will have to remove them.
There's a missing file in the mono 3.4 tarball that causes make install
to fail right after it installed the 2.0 binaries. The other versions never get insalled, which is why you are missing 4.5
cd to the unpacked tarball and create the file yourself:
cd */path/to/unpacked*
echo -e '<Project xmlns=<a class="moz-txt-link-rfc2396E" href="http://schemas.microsoft.com/developer/msbuild/2003">"http://schemas.microsoft.com/developer/msbuild/2003">\n <Import Project="..\Microsoft.Portable.Core.props" />\n <Import Project="..\Microsoft.Portable.Core.targets" />\n</Project>' > mcs/tools/xbuild/targets/Microsoft.Portable.Common.targets
and then continue as usual (not sure if you have to configure and make again)
./configure --prefix=/opt/mono-3.4
make
make install
What have you done to implement portable code? Are you sure you have no platform-dependencies? Implement a one-liner:
System.Console.WriteLine("OK!");
Remove all unnecessary dependencies and use framework 2.0 (most stable).
If that works, the problem is not the Mono installation on Linux but something in your code.
The problem is your mono files are installed in /usr/lib/mono
but it is looking for them in /usr/local/lib/mono
which doesn't exist.
Copying the whole directory /usr/lib/mono
to /usr/local/lib
got it working for me.
This set of instructions (not the Ubuntu ones) worked for me in Ubuntu 12.04, I think.
I also cloned from github and followed their ./autogen.sh; make; make install; make check
instructions just in case.