[Gtk-sharp-list] DllImport on *.so files

Paolo Molaro lupus@ximian.com
Mon, 18 Aug 2003 15:31:52 +0200


On 08/17/03 fd wrote:
> This is a known issue and an inherent problem with late-binding to
> shared objects. Because most users of Mono are developers (with all the
> required development packages) right now, it hasn't been a priority to
> fix. The Debian packages address the problem by depending on the
> development packages of required libraries, which, as you point out, is
> rather a lot of overhead for just one symlink as far as the user is
> concerned.
> 
> We looked into finding an intelligent solution to the problem a few
> months back, but nothing struck us as immediately obvious, so the issue
> still stands.

We have already a nice solution in place and it's even documented.
There is no need to depend on the development packages, people just need
to add the right entries to the config file.
The library name specified in the DllImport attribute is
platform-specific, it can at best be considered as a hint.
In practice, we set it to the string that is understood by the MS
runtime running on windows, so that our assemblies are portable.
Mono provides a mechanism in the configuration file to get the real
library name corresponding to the hint in the DllImport attribute.
Currently, the mapping used for Gtk# is something like:

<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so" />

This is correct, but requires the gtk+ development package to be
installed. A better entry is to use:

<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so.0" />

This will load the same library through it's versioned soname, just like
when a normal C program is linked against libgtk+. No need for extra
libraries, you can just fix the config file on your system or test and
submit a patch for the config file installed by default by mono.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better