pkg-config
Query library compiler and linker flags
TLDR
Get compiler flags
SYNOPSIS
pkg-config [options] [packages]
DESCRIPTION
pkg-config retrieves compiler and linker flags needed to build software against installed libraries. It reads metadata from .pc files that libraries install, providing the correct include paths, library paths, and link flags.
Build systems like autotools, CMake, and Meson use pkg-config to locate libraries portably. The --cflags flag returns compiler flags (include paths), --libs returns linker flags, and --modversion shows the installed version. Version constraints can be checked with --atleast-version.
PARAMETERS
PACKAGES
Package names.--cflags
Compiler flags.--libs
Linker flags.--exists
Check existence.--modversion
Show version.--list-all
List packages.
CONFIGURATION
PKG_CONFIG_PATH
Colon-separated list of additional directories to search for .pc files.PKG_CONFIG_LIBDIR
Override the default .pc file search path entirely.
CAVEATS
Requires .pc files. PKGCONFIGPATH for custom locations.
HISTORY
pkg-config was created to simplify library compilation and linking.
