[Mono-devel-list] GAC and third party libraries: post Beta planning.

Kamil Skalski nazgul at omega.pl
Thu May 6 03:43:25 EDT 2004

Wednesday 05 May 2004 19:55, Miguel de Icaza wrote:

> Hello guys, [Paco, please read until the end]
>     This is a follow up to the GAC and third party libraries post from
> two days ago.  The situation right now is far from ideal, and we are
> trying to find the sweet spot for developers.
>     So the problem is: libraries today are installed into the GAC, but
> libraries in the GAC are not visible to the compilers.
>     How should a compiler reference libraries in this GAC world?  The
> solution that we are shipping with today depends on all libraries being
> in the same directory as the mcs.exe compiler (gtk-sharp being an
> exception, but with the help of a hack we put in the release on the mcs
> script, it works for it as well).
>     I would like to propose a change to our current setup, which I
> think would simplify things. This idea has multiple layers:
> 	* Using pkg-config
> 	* Changing our use of pkg-config
> 	* Adding pkg-config support to the mcs compiler.
> * Using Pkg-config to record library locations.
>     We have been considering is to encourage developers to only use
> pkg-config to specify libraries, so things would look like this:
> 	mcs program.cs `pkg-config --libs gtk-sharp Robotron`
> Or Makefile users would have:
> 	FLAGS = `pkg-config --libs gtk-sharp Robotron`
> 	a.exe: a.cs
> 		mcs a.cs $(FLAGS)
> The pkg-config file, uses the link lines from the .pc file installed
> for a package, they look like this (this is the one for gtk-sharp).
> 	PACKAGE=gtk-sharp
>         prefix=/mono
>         exec_prefix=${prefix}
>         libdir=${exec_prefix}/lib
>         Name: Gtk#
>         Description: Gtk# - GNOME .NET Binding
>         Version: 0.91
>         Libs: -lib:${libdir}/mono/$(PACKAGE) -r:glib-sharp -r:pango-sharp
> -r:atk-sharp -r:gdk-sharp -r:gtk-sharp
> * Changing our use of pkg-config

Yesterday we have come up with exactly the same solution in Nemerle compiler. 
I've implemented it, so now we use
ncc.exe gtk.n -p gtk-sharp 
(or -pkg or -pkg-config)

The only addition to your design is the case when executing pkg-config fails 
(package was not found, or there is no pkg-config program on system) = we 
leave -r gtk-sharp then, so there is some (little) chance, that library would 
be found without pkg-config.

It would be great to standardize to this solution. So also core libraries 
would be mentioned in some .pc file (System.dll, etc.)

In my implementation, I've used simple trick - if I encounter -p switch I take 
supplied string, feed it to pkg-config --libs

 def execute_pkgconfig (opt : string) {
        def pkg = System.Diagnostics.Process ();
        pkg.StartInfo.FileName <- "pkg-config"; 
        pkg.StartInfo.Arguments <- ("--libs " + opt);

and later recursively parse result of execution.

Kamil Skalski

More information about the Mono-devel-list mailing list