LinuxCommandLibrary

pkg-config

TLDR

Get compiler flags

$ pkg-config --cflags [library]
copy
Get linker flags
$ pkg-config --libs [library]
copy
Get all flags
$ pkg-config --cflags --libs [library]
copy
Check if library exists
$ pkg-config --exists [library] && echo "Found"
copy
Get library version
$ pkg-config --modversion [library]
copy
List all packages
$ pkg-config --list-all
copy

SYNOPSIS

pkg-config [options] [packages]

DESCRIPTION

pkg-config provides library compile/link flags. Build system helper.
The tool retrieves library metadata. Used in build scripts.
pkg-config finds libraries.

PARAMETERS

PACKAGES

Package names.
--cflags
Compiler flags.
--libs
Linker flags.
--exists
Check existence.
--modversion
Show version.
--list-all
List packages.

CAVEATS

Requires .pc files. PKGCONFIGPATH for custom locations.

HISTORY

pkg-config was created to simplify library compilation and linking.

SEE ALSO

make(1), gcc(1), pkgconf(1)

Copied to clipboard