pkg-config and Mono, was: Re: [Mono-devel-list] GAC issues and third party libraries.

Paul Thomas PTHOMAS at
Wed May 5 16:32:05 EDT 2004

>>> Miguel de Icaza <miguel at> 5/3/2004 12:36:31 PM >>>
>   Alternatively, more elite users can do:
>	mcs `pkg-config --libs gtk-sharp` hello.cs

When I run 'pkg-config --libs mono' I get:

-Wl,--export-dynamic -pthread -L/opt/gnome/lib -lmono -lpthread -lm
-lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0

These appear to be the library options to pass into gcc, not mcs.

I would like to use a .pc file to set, and pkg-config to get, the /lib:
and /r: options for my Mono projects.  I first looked into using .Libs
in the .rc file to define the /lib: and /r: options, and 'pkg-config
--libs' to get them.  However, 'pkg-config --libs' returns my options
merged with the mono options shown above.  This is because in my .pc
file I also have:

Requires: mono >=0.31

The pkg-config man page says this about the --libs option:

"This option is identical to "--cflags", only it prints the  link
flags. As with "--cflags", duplicate flags are merged (maintaining
proper ordering), and flags for dependencies are included in the

Because I require mono, the mono "libs" options, as well as the "libs"
options of all of its dependencies, are being included.  This wouldn't
be a problem except that these are gcc-like options, not mcs options.

It doesn't seem safe to me to re-use --libs for both C and Mono
compiler options.

Instead, I'm thinking of defining the following variable in my .pc

MONO_LIBS=/lib:${libdir} /r:myassembly1.dll /r:myassembly2.dll

I can then use 'pkgconfig --variable=MONO_LIBS mypackage' to get these


1. I can get my Mono compiler options without worrying about
contamination with C compiler options from dependencies.
2. If my package also supports C APIs, I can continue to use --cflags
and --libs in the traditional way.


1. I don't automatically get merged Mono compiler options from
2. I'm inventing my own mechanism and not using a standard one.

Is the there a prescribed or de-facto standard for using pkg-config for
Mono-based packages?  Are there plans to modify pkg-config to support

Any guidance will be appreciated.


More information about the Mono-devel-list mailing list