$linuxjunkies
>

pkgconf(1)

Query information about installed libraries and their compile/link flags.

UbuntuDebianFedoraArch

Synopsis

pkgconf [OPTION]... [LIBRARY]...

Description

pkgconf is a program which helps to configure compiler and linker flags for development libraries. It reads metadata from .pc (pkg-config) files to return the correct compiler flags, library names, and other information needed to compile and link against libraries.

It is a faster, more portable replacement for the original pkg-config tool, maintaining compatibility while offering improved performance and additional features for package discovery and introspection.

Common options

FlagWhat it does
--cflagsOutput compiler flags (CFLAGS) required to compile with the library
--libsOutput linker flags (LDFLAGS and library names) required to link with the library
--modversionDisplay the version of the specified package
--existsExit with success status if all packages exist, failure otherwise (no output)
--list-allList all available packages installed on the system
--requiresDisplay the dependencies (Requires) of the package
--variable=VARPrint the value of a specific variable from the .pc file
--cflags-only-IOutput only the -I include directory flags
--libs-only-lOutput only the -l library name flags
--libs-only-LOutput only the -L library directory flags

Examples

Get both compiler and linker flags for OpenSSL library

pkgconf --cflags --libs openssl

Display the installed version of GTK+ 3.0

pkgconf --modversion gtk+-3.0

Check if libcurl development package is installed on the system

pkgconf --exists libcurl && echo 'libcurl is installed'

List all available packages and filter for glib-related ones

pkgconf --list-all | grep glib

Compile a file using compiler flags automatically retrieved from libxml2 package

gcc -c myapp.c $(pkgconf --cflags libxml-2.0)

Print the library directory path variable from the OpenSSL .pc file

pkgconf --variable=libdir openssl

Link an object file against SQLite3 using automatically determined linker flags

gcc myapp.o -o myapp $(pkgconf --libs sqlite3)

Related commands