Subject: libtool *.la files vs. pkg-config *.pc files
To: NetBSD Packages Technical Discussion List <tech-pkg@NetBSD.ORG>
From: Greg A. Woods <>
List: tech-pkg
Date: 11/05/2004 17:14:01
As most of you probably already know it seems a number of package
authors are grossly negligent when it comes to undertanding and fully
maintaining their package interdependencies, particularly when it comes
to object libraries.

In the M$-Windoze world this problem is part of what is often called
"DLL Hell".

As others have already said it's sad to see it happening at an ever
increasing frequency in the open source world too.

Part of the problem is that the tools that are available to manage the
enormous complexity forced on us by some of the big dreamers out there
are sometimes not even used (even though often those tools are seriously
flawed in many ways -- they're still better than nothing).

A prime example is this "pkg-config" invention (and all those similar
monstrosities which preceeded it, most of which still tag along with

For example I recently encountered the following error while trying to
configure x11/gtk2 (from the pkgsrc-2004q4 branch) on my 1.6.x alpha
(this is from the resulting config.log file):

    configure:28182: checking for XOpenDisplay in -lX11
    configure:28212: gcc -o conftest -O2 -mno-soft-float -mcpu=21164a -g -DLOCKDEBUG -mieee -pipe -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2 -Wall -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2 -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/X11R6/lib -Wl,-R/usr/X11R6/lib conftest.c -lX11  -Wl,-R/usr/pkg/lib -Wl,--rpath -Wl,/usr/pkg/lib -Wl,--export-dynamic -L/usr/pkg/lib -L/usr/X11R6/lib -lpangoxft-1.0 -lXft -lfreetype -lz -lXrender -lX11 -lfontconfig -lexpat -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -liconv -lintl  >&5
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_map_cache_clear'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_map_get_type'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_map_create_context'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_map_shutdown'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_get_type'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_lock_face'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_has_char'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_get_glyph'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_get_unknown_glyph'
    /var/package-obj/x11/gtk2/work/.buildlink/lib/ undefined reference to `pango_fc_font_unlock_face'
    configure:28218: $? = 1

As an aside you'll no doubt agree the error spewed by "./configure" was
exceedingly misleading too:

    checking for XOpenDisplay in -lX11... no
    configure: error: *** libX11 not found. Check 'config.log' for more details.
    *** Error code 1

Now on to why configure tripped up:

From the pkg-config pangoxft.pc file (with the -L and -W noise removed):

    Libs: -lpangoxft-1.0 -lXft -lfreetype -lz -lXrender -lX11 -lfontconfig -lexpat  

According to "pkg-config --libs-only-l pangoxft":

    -lpangoxft-1.0 -lXft -lfreetype -lz -lXrender -lX11 -lfontconfig -lexpat -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -liconv

From the libtool file (with the -L and -W noise

    dependency_libs='-lpangoft2-1.0 -lpango-1.0 -lXft -lfontconfig -lXrender -lfreetype -lXrender -lX11 -lfontconfig -lfreetype -lz -lexpat -lexpat -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -liconv -liconv -lintl'

Hmmmm....  so libtool, despite it's many other failings, did somehow
manage to record the fact that libpangoxft depends on libpangoft2,
whereas the libpangxft.pc file supplied with pango does not.

Sadly "ld" did not record all the inter-library dependencies for some
reason (perhaps because libtool forgot to tell it to do so?):

    $ cd /usr/pkg/lib
    $ ldd libpango*.so
             -lintl.0 => /usr/lib/
             -lz.0 => /usr/lib/
             -lintl.0 => /usr/lib/
             -lX11.6 => /usr/X11R6/lib/
             -lintl.0 => /usr/lib/
             -lz.0 => /usr/lib/
             -lX11.6 => /usr/X11R6/lib/
             -lintl.0 => /usr/lib/

What do do?

I suppose for my purposes, and for pkgsrc in general, it's probably best
to simply patch the libpangoxft.pc file so that pkg-config gives the
full list of dependencies.....

(I've got a raft of similar problems that don't involve pkg-config, such
as the fact that libtiff now really needs libm, at least on alpha, but
most libtiff users don't include -lm when necessary....)

The bigger question though is whether or not pkg-config should get its
list of dependent libraries from the file(s) where possible,
or not.

Another question is whether or not anyone else has seen anything
remotely like this when building things using pango.

						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <>
Planix, Inc. <>          Secrets of the Weird <>