pkg-config chaining

Quick note: chaining pkg-config .pc files using the Requires: statement works. As in, flags from the required packages are indeed added to the flags for the requiring package, including -L flags (which I was wondering about in particular, w.r.t. PR Itseez/opencv#3792).
This might seem obvious as that’s quite the purpose of this statement, but I wasn’t sure what it did exactly.

Here is a quick example.

requirer.pc :


# requirer pkg-config file

Name: requirer
Description: I require some other package.
Version: 1.0
Requires: requiree
Conflicts:
Libs: -lrequirer

requiree.pc :


# requiree pkg-config file

Name: requiree
Description: I am required by some other package.
Version: 1.0
Requires:
Conflicts:
Libs: -L/some/libdir/path -lrequiree

pkg-config output:


$ PKG_CONFIG_PATH=. pkg-config --libs requirer
-L/some/libdir/path -lrequirer -lrequiree

So not only are the entries from the required packages added to the entries for the requiring package, but they are also added intelligently in that -L entries are prepended and -l entries appended.

Good to know.

Leave a Reply

Your email address will not be published. Required fields are marked *