[Mono-devel-list] Proposal: Library Loading

Jonathan Pryor jonpryor at vt.edu
Wed Apr 14 07:53:29 EDT 2004

On Wed, 2004-04-14 at 01:31, Miguel de Icaza wrote:
> Hello,
> Am sorry we missed each other on irc.  

Me too.

> The idea we are thinking about is a bit simpler than the proposed solution.  
> Every library provider that needs DllImport functionality needs to
> install in $sysconfdir/mono/ a file with the extension .libmap.

I don't think this will work as-is.  I'll detail below.

> For example, Gtk# would install something like this:
> <configuration>
> 	<dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.so.0.200.3" />
> </configuration>
> Notice that the full version for the .so file is specified on the
> .libmap file.

And this is the problem: the full version is specified.  If no further
intelligence is present, then I won't be able to use Gtk# anymore, as I
have libglib-2.0.so.0.200.2 installed.  Since the version numbers don't
match exactly (and mine has a lower patch number), dlopen(3) won't be
able to find the library, so I won't be able to run my programs anymore.

I think this is also brittle in the face of change: if GLib 2.2.4 came
out tomorrow (with a full version of libglib-2.0.so.0.200.4) and was
installed on the users machine (yay Red Carpet!), the version number
would no longer match exactly, and dlopen(3) would not be able to find
the new library.

Consequently, previously working apps would no longer work, "just
because" the user upgraded their GLib installation.

I don't think it would be acceptable to require that GLib (1) know about
Mono, and (2) keep Mono up-to-date about which version is installed.

This is why whatever solution Mono uses *must* be intelligent enough to
search for compatible versions: if the major.minor version doesn't
exist, fall-back and try the major version.  If that doesn't exist, try
it without a version.  If that doesn't exist, throw an exception.

> Now, to install the libmap file a program must be invoked, this program
> is responsible for copying the .libmap file into the $syconfdir
> directory, and generate a fresh $sysconfdir/mono/config
> So something like to install:
> 	mlibconf -i gtk-sharp.libmap
> And to remove:
> 	mlibconf -e gtk-sharp.libmap

I forget who originally mentioned it, but I don't think the distributors
will like the requirement to run a tool during the postinstall step. 
Then again, it needs to be done for the GAC anyway, so maybe this isn't
so bad.

> The benefit is that Mono only needs to open *one* configuration file
> instead of having to get a directory listing, and load multiple files,
> which impacts startup time. 

Pardon my ignorance, but is the config file *really* needed at program
startup?  I thought it was only needed when DllImport statements were

If that's the case (and I hope it is), then it would only impact the
startup time of programs that used DllImport, not all programs (just
many of them ;-), and the config directory could be lazy initialized on
the first load of a native library.

Michal Moskal already noted that the directory reading might not be that
slow, anyway.  Guess we'd have to test it.

 - Jon

More information about the Mono-devel-list mailing list