gentuba
gentuba

Reputation: 103

Trying to run a mono bundled program, but getting missing libgdiplus exception

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.

Upvotes: 1

Views: 2197

Answers (3)

Frank Pfattheicher
Frank Pfattheicher

Reputation: 432

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"/>

Upvotes: 6

IanNorton
IanNorton

Reputation: 7282

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

Upvotes: 0

lupus
lupus

Reputation: 3973

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.

Upvotes: 2

Related Questions