1

I am currently trying to get my C# program to run on Linux. Using mono on my Linux machine, the program runs fine. So I used mkbundle and it all compiled and such correctly. But when I try to run the bundled program on any other Linux machine I get this error:

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the 
type initializer for System.Windows.Forms.XplatUI ---> 
System.TypeInitializationException: An exception was thrown by the type initializer for 
System.Drawing.GDIPlus ---> System.DllNotFoundException: libgdiplus.so.0

This is the mkbundle command I used:

mkbundle --static program.exe --deps -o a.out

I also tried using mkbundle2 with no luck.

I thought maybe there was a way to specifically include libraries with mkbundle (like telling where to find libgdiplus). It should be linked in when I use mkbundle, but I guess it isn't because when I run my program on any other Linux machine (that isn't running mono), I get this error.

Both machines are running Ubuntu 10.10 AMD64.

Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
gentuba
  • 103
  • 1
  • 1
  • 5

3 Answers3

6

The mono 3.0 config file for windos has bad entries dor the libgdiplus references.

Change the two lines of the file C:\Program Files (x86)\Mono-3.0.2\etc\mono\config as follows:

 <dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" os="!windows"/>
 <dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" os="!windows"/>
  • I think this answer does not help the questioner, as it affects Windows. But for me it was very helpful and made me able to run Mono under Windows. Thanks. – Tobias Apr 24 '13 at 14:32
  • i don't have a xamarin bug report account, can somebody report this to the mono team ? – tux_mind Aug 01 '14 at 12:47
2

Extrernal helper libraries are not bundled in the executable, so you will either need to distribute libgdiplus as well, or use the -oo option to create an object file that you will link in a program together with the libs that you need. Of course you will also have to add a dllmap entry to map from, for example, libgdiplus to __Internal.

Note that if you just distribute the program generated by mkbundle as is, you're violating mono's free software licence, so unless, for example, you have a special licence from Novell, or you program is free software or you also distribute the object files of the app so people can relink themselves, you shouldn't use mkbundle.

lupus
  • 3,963
  • 1
  • 18
  • 13
  • Can you provide an example of including libgdiplus as a lib in the cc linker/compiler after the mkbundle step? – S.Richmond Aug 18 '14 at 02:19
0

If on your "foreign" machine you run this:

ldd a.out

You should be able to see what shared libraries it is expecting. You may need to distribute libgdiplus.so with your program or perhaps statically link in libgdiplus.a

IanNorton
  • 7,145
  • 2
  • 25
  • 28