Question

I have a very simple .NET commandline application that I want to port to OS X.
I can run it with "mono app.exe"
However, the destination machines won't have mono installed. So, I wanted to bundle mono inside the app.

In order to do this, I used mkbundle2:

mkbundle2 -o bundledapp.exe app.exe --deps

This works without errors, output:

OS is: Darwin
Sources: 1 Auto-dependencies: True
  embedding: /Users/kclement/Projects/app/build/app.exe
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/2.0/mscorlib.dll
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/gac/System/2.0.0.0__b77a5c561934e089/System.dll
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/gac/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/gac/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/gac/System.Security/2.0.0.0__b03f5f7f11d50a3a/System.Security.dll
  embedding: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/mono/gac/Mono.Security/2.0.0.0__0738eb9f132ed756/Mono.Security.dll
Compiling:
as -arch i386 -o temp.o temp.s 
cc -g -o bundledapp.exe -Wall temp.c `pkg-config --cflags --libs mono`  temp.o
Done

I can execute this on the build machine. When I execute on a machine without mono however, it won't run.

Output:

dyld: Library not loaded: /Library/Frameworks/Mono.framework/Versions/2.6.1/lib/libmono.0.dylib
  Referenced from: /Users/kristof/./bundledapp.exe
  Reason: image not found
Trace/BPT trap

What am I missing? How do I include the actual mono runtime?

EDIT: I also tried adding the --static flag. That gives my app another license however, which I'm not sure I want. I then no longer complains about libmono, but about libgthread-2.0.0.dylib

Was it helpful?

Solution

So, the problem is that mkbundle links to some file that reside on my mac, where I expected it to bundle them. You can clearly see that by looking up the linked resources with the command:

otool -L ./BundledApp

(where bundledApp is the output of mkbundle2)

In order to fix it, I ended up using the mkbundle nant-tasks from the monobjc project:
http://www.monobjc.net/index.php?page=mkbundle-task

I think they are pretty much an automated version of what I found here:
http://code.google.com/p/cocoa-sharp-dev/wiki/RedistributableAppWithoutInstallingMono
But that gave me exceptions.

The Monobjc nant task works without any issues, and is by far the easiest solution. I still have multiple files but that's ok, at least it works now.

OTHER TIPS

Try running:

mkbundle -o bundledappname program.exe --deps

(use a different name for the bundle rather than the same as your program.exe and do not put .exe extension to the -o flag)

Also, did you tried macpack ?

For more information on how to create bundles read here and the fine manual of mkbundle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top