On Thu, Aug 02, 2018 at 11:45:00AM +0200, Dominique Martinet wrote:
Wearing a lib developer hat, I don't see how you can make a .pc
that
doesn't overlink if you provide something a bit entangled with other
libs.
The problem is that if your headers use any sub-lib type you need to add
that lib in Requires: so that --cflags will pull that lib's include
path; and that will in turn add that sub-lib to the linked libs even if
the program likely doesn't care about it (either because they didn't
even use that part of your lib, or because all uses of that lib will be
done through your own anyway so it wasn't required in the first place)
Then it is clearly a task for pkg-config (and libtool) to handle it better.
If the --libs it provides contains some mandatory and some optionally needed
libraries, then it should differentiate between them and use
-Wl,--push-state,--as-needed ... -Wl,--pop-state
around those that are optionally needed. If all libraries from those tools
are optional, perhaps it should use it always.
Changing the behavior of say -lpthread on the command line is a bad idea,
many projects really expect it to mean that the mentioned library is linked
in and if it no longer does, it causes silent breakage. Forcing users to do
-Wl,--push-state,--no-as-needed ... -Wl,--pop-state
whenever they really mean to link some library is too hostile.
Jakub