[gnutls-dev] pkg-config file for libgnutls
Simon Josefsson
simon at josefsson.org
Fri Feb 16 08:03:13 CET 2007
Andreas Metzler <ametzler at downhill.at.eu.org> writes:
> On 2007-02-15 Simon Josefsson <simon at josefsson.org> wrote:
> [...]
>> Possibly we could have a 'Requires: libtasn1' line added,
>
> It would not be the right thing imho. Afaik Requires is rarely the
> right thing for dependencies that are libraries (Only if the API
> of the required library is intentionally exposed by original library.)>
The GTK people seem to use plenty of Requires:
jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gtk+-2.0.pc
Requires: gdk-${target}-2.0 atk cairo
jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/atk.pc
Requires: gobject-2.0 gmodule-no-export-2.0
jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gobject-2.0.pc
Requires: glib-2.0
jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gdk-x11-2.0.pc
Requires: gdk-pixbuf-2.0 pango pangocairo fontconfig x11 xext xrender xinerama xi xrandr xcursor xfixes
...
Which leads to, on my Debian box:
jas at mocca:~$ pkg-config --libs gtk+-2.0
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
jas at mocca:~$
Note that even '-lm' and '-lX11' is there. IIRC, the gtk people
invented pkg-config, so they should hopefully use the best practice.
>> which I
>> think would have the effect as you want: 'pkg-config --libs gnutls'
>> will mention -ltasn1.
>
> Well, it shouldn't.
That statement seem to be in contrast with the example above and also:
> There are archs that require direct linking of dependent libaries
> i.e. if your program is using gnutls_init() you'll need to build it by
> using
>
> cc -L/usr/lib -lgnutls -ltasn1 -lgcrypt -lgpg-error foo.c
>
> since libgnutsls itself is linked against libtasn.
If some archs require that all dependent libraries are mentioned at
link-time, it seems 'pkg-config --libs gnutls' should mention all of
the required library. Just like the 'gtk+-2.0' example above.
> The point of pkg-config is to centralize the knowledge about archs
> needing additional linking and which do not, "pkg-config --libs
> gnutls" will list the additional dependencies (that is the stuff in
> Libs.private) if it is necessary for that arch and won't do otherwise.
Oh! Is this what is happening? Is pkg-config clever enough to do
this?
Anyway, I consider pkg-config a poor design since it doesn't use the
test-for-a-feature-approach. It is better if applications needing
GnuTLS test for it directly, using something like Bruno's M4 macros.
Maybe I should write about this in the manual... Anyway, I'd be happy
to change GnuTLS' pkg-config files to whatever seems to be the best
common practice.
/Simon
More information about the Gnutls-devel
mailing list