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?


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.


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


              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

              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'

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

$ pkg-config --variable pcfiledir gtk+-3.0

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.