[Mono-list] Creating a stand-alone linux executable

Tim Martin tim at asymptotic.co.uk
Tue Jul 20 10:39:45 EDT 2010


Hi,

I have an executable that I've written on Windows, and would like to 
package for linux. I have got the executable to run under Mono (2.4.2.3) 
on my linux dev box (Ubuntu Jaunty). I'd like to package this into a 
stand-alone executable that can be deployed to other linux boxes that 
don't have the Mono libraries installed.

Various things I've seen indicate that mkbundle might be a way to 
achieve this. I can't get the automatic dependency inclusion to work, 
but it partially works if I list the executable and all the DLLs on the 
command line. I assume if I'm going to do this that I need to list every 
Mono DLL that is needed to run the final executable. I haven't been able 
to find a way to determine which Mono DLLs are necessary, but I've added 
to the list every time the executable fails with a missing DLL, and I 
have something like the following:

$ mkbundle --static -o mybundle MyApp.exe <app-specific DLLS> 
/usr/lib/mono/2.0/mscorlib.dll /usr/lib/mono/2.0/System.dll 
/usr/lib/mono/2.0/System.Drawing.dll /usr/lib/mono/2.0/Mono.Posix.dll 
/usr/lib/mono/2.0/System.Configuration.dll 
/usr/lib/mono/2.0/System.Xml.dll /usr/lib/mono/2.0/System.Data.dll 
/usr/lib/mono/2.0/System.Transactions.dll 
/usr/lib/mono/2.0/System.Web.Services.dll 
/usr/lib/mono/2.0/System.EnterpriseServices.dll 
/usr/lib/mono/2.0/System.Web.dll

(I'm aware that --static has licensing implications, I can probably work 
round that when I finally deploy, but I wanted to keep things simple 
ATM. --static has nothing to do with linking the .dll files, right?)

When I run this on a box (Ubuntu Intrepid) that doesn't have Mono 
installed, I get:

Message: An exception was thrown by the type initializer for 
Mono.Unix.Native.Syscall
Stack Trace:
   at System.Windows.Forms.XplatUIX11.UpdateMessageQueue 
(System.Windows.Forms.XEventQueue queue) [0x00000]
   at System.Windows.Forms.XplatUIX11.GetMessage (System.Object 
queue_id, System.Windows.Forms.MSG& msg, IntPtr handle, Int32 
wFilterMin, Int32 wFilterMax) [0x00000]
   at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, 
System.Windows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 
wFilterMax) [0x00000]
   at System.Windows.Forms.Application.RunLoop (Boolean Modal, 
System.Windows.Forms.ApplicationContext context) [0x00000]
   at System.Windows.Forms.Application.Run 
(System.Windows.Forms.ApplicationContext context) [0x00000]
   at Psonar.Desktop.Forms.Program.Main (System.String[] args) [0x00000] 
Inner Exception Message: libMonoPosixHelper.so
Inner Exception Stack Trace:
   at (wrapper managed-to-native) Mono.Unix.Native.Syscall:_L_ctermid ()
   at Mono.Unix.Native.Syscall..cctor () [0x00000]

It's not obvious that this is due to a missing DLL, but I guess it 
probably is since it works fine on the other box.

So I guess my questions are:
1) Is this a sane way to generate a stand-alone executable?
2) What is a saner way?
3) What DLL (if any) am I missing?

Thanks for any suggestions,

Tim


More information about the Mono-list mailing list