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

Paolo Molaro lupus@ximian.com
Tue, 19 Aug 2003 18:47:00 +0200

On 08/19/03 Dag Wieers wrote:
> > <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.
> Nice, and I guess the mapping is used at buildtime ?

The mapping is used when the P/Invoke function is called.

> Still this does not guarantee that the .dll's work with the specific 
> libraries installed, if I'm correct.

There is no way for any CLR implementation to fix the billions of ways
a programmer can screw up:-) When you use P/Invoke you're implicitly
using one binary interface of a library, so you must make sure that
specific library is loaded (hence the use of the versioned soname in the
dll mapping instead of the simple .so map).

> Eg. gtk-sharp requires gtkhtml3 and Red Hat only ships gtkhtml2 (and 
> building gtkhtml3 is a real mess as it requires a newer gtk2 etc etc...)

If gtk-sharp really requires version 3, you can't use version 2.

> Some way of verifying if function-calls map with existing libraries would 
> be prefered.

With C libraries you can check just the function name: not very useful.

On 08/19/03 Gustavo Ramos wrote:
> For the mono framework, the solution shouldn't be too hard, and
> this should be nearby Paolo's post. Ok, we won't need the development
> packages if we change the config of mono, to map the versioned lib. But
> that isn't enough, because the need of hard-coding the version number.

The hard-coded soname is the least of your worries: each P/Invoke call
basically hardcodes the ABI of a library, so much info is already
AFAIK, the only issue left to implement from mono's point of view is to
load a config file per assembly so that there's no need to change the
master configuration file. Any takers?


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