[Mono-devel-list] Proposal: Library Loading

Miguel de Icaza miguel at ximian.com
Wed Apr 14 01:31:49 EDT 2004


Hello,

> This came up on #mono today in the context of Fedora and package
> management, so I figured I'd document the current idea for discussion
> and possible future implementation [1].
> 
> The Problem:
> 
> DllImport doesn't allow developers to specify which library version to
> load at runtime.  Thus, with code such as:
> 
> 	[DllImport ("foo")]
> 	private static extern void foo ();
> 
> Mono will attempt to load "libfoo.so" at runtime.
> 
> There are three problems with this:

Am sorry we missed each other on irc.  

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.

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.

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

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. 

the one in $sysconfdir/mono/config that contains the full pathnames.

miguel.



More information about the Mono-devel-list mailing list