GNOME Bugzilla – Bug 328699
pkg-config --libs gtk+-2.0 listing unneeded libraries
Last modified: 2006-01-26 15:08:32 UTC
pkg-config --libs gtk+-2.0 for gtk 2.8 lists libraries that don't need to be linked directly to a program using gtk2 such as pangocairo, cairo, etc. The program that just wants to link to gtk2 shouldn't be linked to these libs. In addition of making the program binary larger and slower to load this way, it makes the program incompatible with systems that have older versions of gtk+2, though the program itself doesn't use any functionality of the new version or the mentioned libraries. pkg-config --libs gtk+-2.0 should list just the libs that contain the symbols that are in the public gtk include files.
pangocairo and cairo are integral parts of the GTK+ API, not having them part of the pkg-config output would make things inconvenient for application writers. (And you have to have them in the --cflags output in any case since gtk.h includes the headers.) If you want to create a binary that works against older versions of GTK+ you must, for this and other reasons, compile against that older version.
Forget about the compatibility part of the issue. i shouldn't expect that kind of compatibility. What about the other argument: that you force everybody to link against libraries they don't necessarily use directly? Is libX11 also an integral part of the GTK+ API? Not on Windows or on Mac OS X. and even worse, this kind of scenario could happen: i link the application with pkg-config, and that includes the dependancy on libpango-1.0.so.0. But in the meantime a new version of gtk+ is released that depends on libpango-1.2.so.0. The soname for the gtk+ stays the same. So my app loads libpango-1.0.so.0 and and gtk+ loads libpang-1.2.so.0.. and we get a nice segfault.