Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As far as I know, both Wine and Mono are used to run Windows applications under Ubuntu.

So I was wondering

  1. what their differences are? Are they both virtual machines? Or does each belong to some other category?
  2. It is better When to use which for what kinds of Windows applications? For example, those applications that may or may not require .net Framework.
  3. Do they depend on each other? Are they required to install together? Or does each work independently without existence of the other?

Thanks and regards!

share|improve this question

2 Answers 2

up vote 12 down vote accepted

Successfully running a program requires that three things match:

  • CPU instruction set (Eg. x86 in your PC, ARM in your mobile phone, PowerPC in some Apple Macs, Java bytecode for Java Applets, CLI for ".Net"/Mono applications)
  • Binary File Format (Eg. PE/COFF ".exe" for Microsoft Windows, .jar for Java Applets, PE32 ".exe", ELF on Unix/Linux)
  • Application Programming Interface; (Eg. POSIX on Linux/Unix, Cocoa for Mac OSX, Win32 on Microsoft Windows, Base Class Library for ".Net"/Mono applications).

You can increase the chance of matching all three by having emulators/interpreters (for other CPU instruction sets), by having extra file loaders (for foreign file-formats), and having additional programming libraries providing more APIs.

Note also, that some processors can natively execute more than one instruction set; a PC quite often has x86 and amd64 instruction sets; an ARM processor can execute four: ARM32/Thumb/Java bytecode/ThumbEE. Some operating systems can provide more than one API natively too (Microsoft Windows provides Win32 and POSIX).

For everything else you need extra software. For running Java programs you need the three parts listed above to make it work: a Java Virtual Machine program to run the bytecode; a way of launching Java programs, and a Java Classlibrary for the programs to call. "Java" is a brandname here for several separate technologies originally developed by Sun, but to a user they are often downloaded as one.

The same applies for ".Net", which is a marketing brandname for several different technologies originally developed by Microsoft: The Common Language Run-time/Base Class Library (CLR) are the API; VES is the loader and Common Language Interface (CLI) is the instruction set.

You don't have to download those technologies from Microsoft, from Sun, or from Intel just because they originally invented something. AMD make processors compatible with Intel's standards; both Apache ("Harmony") and Google ("Android Dalvik") both make a Java-like suite; and Mono provides a CLR/CLI/VES suite. The important thing is that everyone uses the same standards, making them compatible. A DVD disc will play on any DVD player that meets the standard, and an HTML webpage will rendering in any Web Browser meeting the HTML standards.

  • Mono is a CLR/CLI/VES suite that can run on Mac OSX, MS Windows and Linux.
  • Wine is a Win32 API implementation that can run on Mac OSX, MS Windows and Linux.
  • You can run Mono on top of Wine, on top of any operating system.
  • You can run Wine on top of Qemu, on top of any CPU architecture.

So Mono makes CLR .exe applications run, and Wine makes Win32 .exe applications run. The only thing in common is that the filenames end in ".exe"; the contents are completely different and incompatible, so you need the right one.

Just like a Python interpreter will error when presented with Perl (and vis versa), a CLR interpreter will error when presented with x86+Win32, or JVM+Java bytecode. If you can post a link to the particular program that you're wanting to run, myself or somebody else should be able to tell you the exact instruction set, file format and API it was designed for, and what you need to install on Linux to run it. Hope that helps!

(Sometimes you might even need both. For example, the Openbve train simulator is C# and compiled to PE/COFF+CLI+CLR, but can optionally use C binary plugins compiled for PE/COFF+Win32+x86. In this case, you need a Win32 version of Mono under Wine. If the CPU architecture is also, different that would need emulating; so Mono under Wine under Qemu).

share|improve this answer
    
Thanks! (1) do "the way of launching xxx programs", "file loader" and "Binary File Format" mean the same thing? (2) Yes, I was wondering about Expresso ultrapico.com/ExpressoDownload.htm –  Tim Mar 21 '11 at 4:20
    
The operating system must be able to recognise the format of a file as being executable in order to know how to open and run it. Unix shell scripts start with a #!/... "shebang". Other alien file-formats on Linux (Java, Mono, Win32) are configured using the binfmt-misc method. Run grep -r . /proc/sys/fs/binfmt_misc/ to see how the Linux kernel detects different types of executable by looking for "magic" numbers or give-away fingerprints and then passes them to jexec, python, wine, mono, … as appropriate. –  sladen Mar 21 '11 at 4:55
    
Thanks! Do you know what instruction set, binary format and API are for Adobe AIR? I suppose Adobe AIR is a virtual machine? –  Tim Mar 22 '11 at 21:04
    
This answer is way off the mark, very little correct with it: You mention specific about instruction sets, Java byte code is not an instruction set, nor is the CLI. Binary formats, jar is not a binary format. You do not need an API, you can write executables using raw assembly to access the CPU instructions directily, an API is purely a (good) convenience). Executing multiple instructions is irrelevant. The CLR is not an instruction set, its the byte code interpreator (for running different languages in .net). You can't run Wine on top of Qemu –  NGRhodes Jun 20 at 23:01
1  
Thank you for writing a comprehensive answer that provides a lot of useful background information! –  Rafał Cieślak Jun 20 at 23:23

The short answer:

.NET is Microsoft's answer to Java, and Mono is an open source implementation of it. Wine is for native exes and has nothing to do with Mono except that you can maybe run the .NET runtime with it, like any other native Windows software.


The long answer:

To understand the difference between Wine and Mono(and .NET) you must understand the difference between native machine code executables and "common language runtime" aka "virtual machine" executables:

Native machine code executables use instruction codes specific to your processor and are directly executed by it. That means they have to be recompiled for different processors. Wine is able to run native machine code executables for Windows by directly running this executable code and catching any library calls it makes, redirecting them to it's own implementation of the Win32 API.

"CLR" or "VM" executables are not specific to one processor: They need an extra piece of software to enable the processor to run them. Mono/.NET is one such example of this kind of system. .NET programs need the .NET runtime installed even when you run them on Windows. Java works the same way.

So:

1) the difference between Wine and Mono: Wine is for running native machine code executables made for Windows, and Mono is for running Mono/.NET executables which are not necessarily made for any specific platform. Installing Mono on Linux is equivalent to installing the .NET runtime on Windows.

2) If the program you want to run does not use .NET at all, you must use Wine. Mono won't help you at all here.

However, if the program does use .NET you have two options, either of which may or may not work:

  • You can try to run it using Mono. This will fail if the .NET program also uses native functions from the win32 API, which many (but not all) .NET applications made for Windows do.

  • Alternatively, you can install the Microsoft .NET runtime for windows inside Wine, and then run the .NET application through it. You won't be using Mono at all in this case.

3) Wine and Mono do not depend on each other at all, but as stated above, you can use the Microsoft .NET runtime in Wine to run Mono/.NET applications.

share|improve this answer
    
Thanks! (1) So if an application depend on both .NET and win32, the only way is to install .NET on Wine and then install the application on Wine? (2) How to know if an application relies on .NET and/or win32? –  Tim Mar 21 '11 at 4:25
    
Typing file *.exe will show information about the CPU instruction set and file type. If it is a CLI/CLR (".Net"/Mono) application that also uses native Win32 API calls you will need to run it, or look for any file *.dll files that show as being native x86+Win32. –  sladen Mar 21 '11 at 4:45
    
You can also install Mono for Windows in Wine but according to the Wine FAQ it is less likely to work than the .NET runtime. There is no simple way to know if a .NET program uses native win32 calls since there are a bunch of different ways they can do it. Best thing to do is try Mono first, if it doesn't work, try Wine+.NET. –  Alistair Buxton Mar 21 '11 at 5:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.