pkgconf(1)
Query information about installed libraries and their compile/link flags.
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
| Flag | What it does |
|---|---|
--cflags | Output compiler flags (CFLAGS) required to compile with the library |
--libs | Output linker flags (LDFLAGS and library names) required to link with the library |
--modversion | Display the version of the specified package |
--exists | Exit with success status if all packages exist, failure otherwise (no output) |
--list-all | List all available packages installed on the system |
--requires | Display the dependencies (Requires) of the package |
--variable=VAR | Print the value of a specific variable from the .pc file |
--cflags-only-I | Output only the -I include directory flags |
--libs-only-l | Output only the -l library name flags |
--libs-only-L | Output only the -L library directory flags |
Examples
Get both compiler and linker flags for OpenSSL library
pkgconf --cflags --libs opensslDisplay the installed version of GTK+ 3.0
pkgconf --modversion gtk+-3.0Check 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 glibCompile 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 opensslLink an object file against SQLite3 using automatically determined linker flags
gcc myapp.o -o myapp $(pkgconf --libs sqlite3)