Pkg-config

pkg-config is a helper tool which is used to obtain compiler & linker flags when building a package depending on a library.

libtool archives (.la files)
libtool uses specific archive file format (so-called .la files) to provide additional compiler and linker flags when linking against a library.

Implicit vs explicit use
libtool works implicitly whenever it is used to build a library or a program. In the former case, it creates the .la file with used flags; it latter, it reads those files and uses the flags stored in them.

pkg-config needs to be used explicitly. A library has to install .pc files explicitly, and the program built against it needs to query pkg-config explicitly in its build system.

Static vs dynamic linking
libtool provides no distinction between dynamic and static linking. In both cases, the complete list of dependant libraries is passed to linker.

pkg-config explicitly distinguishes between public and private dependencies. This way, when using dynamic linking only actually necessary libraries are passed to linker; and when using static linking, the complete list is used.

Build system-agnostic
libtool archives are usually useful only when libtool is used both to build the library and the final executable. pkg-config is designed to be build system-agnostic instead.

No absolute paths
For a long time Gentoo suffered an issue that libtool archives contained absolute paths to dependent library archives. Effectively, whenever libraries were moved to another library directory, all libraries depending on them became broken and required rebuild. Although the issue is currently worked-around in Gentoo by replacing absolute paths with relative library names, it is still the upstream behavior of libtool.

pkg-config expresses dependencies through package names, and thus is free by design of similar issues.

Custom -config applications
Many libraries provide custom applications of similar function, for example pcap-config. Those applications are compiled along with the library, and often have the relevant compiler & linker flags compiled into itself.

Cross-compilation support
Usually, custom -config applications are built for the specific platform the library is built for. Effectively, they are of no use when cross-compiling if the host is unable to execute code for the target platform.

pkg-config uses simple text files which are platform-independent. Thus, for cross-compilation to work it is only necessary to install pkg-config on the host system and set appropriate PKG_CONFIG_PATH.

Available implementations
In the past, various implementations of pkg-config could be obtained via. Now only, a reimplementation in ANSI C, is available.

Previously (the official implementation, required  causing a circular dependency), and  (OpenBSD implementation, written in Perl) were available but were removed. .