5

I followed a tutorial on GTK which used this command to generate the build flags:

$ pkg-config --cflags --libs gtk+-3.0

This outputs coherent flags. From research, I have found that pkg-config searches for .pc files in /usr/lib/pkginfo, usr/share/pkgconfig, in the /local equivalents, and in the folder indicated by the PKG_CONFIG_PATH variable.

None of the folders contains the GTK file and the environment variable is not set. Where is pkg-config getting the flags?

6

It’s finding them in /usr/lib/x86_64-linux-gnu/pkgconfig/gtk+-3.0.pc (assuming you’re on amd64). On Debian, pkg-config also searches the multi-arch directory for the target, i.e. /usr/lib/$(dpkg-architecture -q DEB_TARGET_MULTIARCH)/pkgconfig.

| improve this answer | |
6

There are a couple of nice tricks given in the man page for getting this information from pkg-config itself.

PKG-CONFIG DERIVED VARIABLES

       pc_path
              The default search path used by pkg-config  when  searching  for
              .pc files. This can be used in a query for the pkg-config module
              itself itself:
                $ pkg-config --variable pc_path pkg-config

       pcfiledir
              The installed location of the .pc file.  This  can  be  used  to
              query  the location of the .pc file for a particular module, but
              it can also be used to make .pc files relocatable.

So for example to see the actual search path for your system / architecture:

$ pkg-config --variable pc_path pkg-config | tr ':' '\n'
/usr/local/lib/x86_64-linux-gnu/pkgconfig
/usr/local/lib/pkgconfig
/usr/local/share/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/pkgconfig
/usr/share/pkgconfig

and to get the location where a particular package's .pc file is found

$ pkg-config --variable pcfiledir gtk+-3.0
/usr/lib/x86_64-linux-gnu/pkgconfig
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.