[Mono-osx] What happens when a Mono is is ran without Mono?

Mac Programmer MacPgmr at fastermac.net
Sun Mar 8 16:22:20 EDT 2009


Any assembly that you want to run under Mono on OS X depends on two  
things:

(1) The assemblies it references

(2) The native libraries these referenced assemblies import.

You can see what your .exe references as follows (in a Terminal window):

monodis --assemblyref myapp.exe

The assemblies listed (and the specific versions) are what your app  
requires.

When you use macpack to create an app bundle, it creates a script  
that launches Mono and runs your app. To distribute your app you  
probably don't want to do this because you don't want to assume that  
your user has Mono installed (not on a Mac, you don't).

Use mkbundle2 to create a normal executable binary for your app and  
also combine all the dependent Mono assemblies for it into the binary.

mkbundle2 -o myapp --deps myapp.exe

You can also create this without combining the referenced assemblies  
(take out --deps). You might need to do that, for example, if you  
want to include the assemblies as separate files (their licenses  
might require that).

Now look at what the resulting executable requires in the way of  
native libraries:

otool -L myapp

Typically you'll see these 4 native libraries:

libmono.0.0.0.dylib
libgthread-2.0.0.dylib
libglib-2.0.0.dylib
libintl.8.0.2.dylib

You would copy these files into your app bundle and use  
install_name_tool to change both the libraries' identification name  
and where myapp looks for these libraries.

That's a brief overview that omits some of the details. If you don't  
understand all of this, then you need to go back and read up using  
man or information on Apple's site. Specifically, what an app bundle  
is, otool, install_name_tool, etc.

A standalone app bundle for a Mono app on OS X weighs in at about  
35MB minimum for a WinForms app, and maybe about 25MB for an app that  
uses the Monobjc bindings. That's seems reasonably modest for a non- 
trivial app. If you compare that, say, to the footprint of the  
QtGui.framework (25MB) and QtCore.framework (7MB), which would be the  
minimum dependencies of a Qt-based app on Mac, the Mono size doesn't  
seem bad at all.

Thanks.

-Phil



More information about the Mono-osx mailing list