| PKG-CONFIG(1) | General Commands Manual | PKG-CONFIG(1) |
pkg-config — a
system for configuring build dependency information
pkg-config |
[options] module ... |
The pkg-config program retrieves
configuration information related to the module
arguments from pc(5) files installed on the system and
prints parts of the retrieved information depending on the specified
options. The most common use is printing the compiler
and linker flags needed to build software that uses the libraries given by
the module arguments.
The pc(5) files are searched for along a path
constructed from the --with-path option, the
PKG_CONFIG_PATH and
PKG_CONFIG_LIBDIR environment variables, and some
compiled-in default directories. The module arguments
correspond to the file names, but without the .pc
filename extension.
Several of the options cause immediate exit. If multiple of these options are given, only the option with the highest priority takes effect and those with lower priority are silently ignored. These options are, ordered by descending priority:
--relocate,
--dump-personality,
--about, --version,
--help,
--atleast-pkgconfig-version,
--list-all, and
--list-package-names: These options cause all
arguments to be ignored.--atleast-version,
--exact-version, and
--max-version: These options only inspect modules
explicitly specified on the command line and do not look at
dependencies.--validate,
--license, --uninstalled,
and --env: These options perform dependency
resolution, but exit after printing the information requested by the
highest-priority option, ignoring other output options that may have been
specified.Several other options require at least one
module argument, produce output, do not cause early
exit, can be combined with each other, but override and disable all
--cflags and --libs
options:
--path,
--print-variables,
--variable: If any of these options is specified,
only the first module argument is used, all other
arguments are silently ignored, and no dependency resolution is
attempted.--print-provides,
--modversion,
--print-requires, and
--print-requires-private: If any of these options
is specified, only modules explicitly specified on the command line are
inspected and no dependency resolution is attempted.--simulate,
--digraph, --solution,
--fragment-tree: These options do not limit
dependency resolution.The most important output options --cflags
and --libs can be combined with each other, but are
overridden and ignored if any of the options listed above are specified.
The complete list of options is as follows:
--aboutpkg-config program to standard output and exit.
Most other options and all command line arguments are ignored.--atleast-pkgconfig-version=versionpkg-config
program, or with success otherwise. Most other options and all command
line arguments are ignored.--atleast-version=version--cflags,
--cflags-only-I,
--cflags-only-other-I) flags, or only the compiler flags that are
not include path flags, respectively. These options imply
--print-errors.--debug--print-errors. If
pkg-config was compiled without defining the
preprocessor macro PKGCONF_LITE, this option also
prints many debugging messages to standard error output.--define-prefix--define-variable=varname=value--digraphPKGCONF_LITE was not defined during
compilation.--dont-define-prefix--dont-relocate-paths--dump-personalityPKG_CONFIG_LIBDIR is not defined, the default list
of include paths that are filtered out when
PKG_CONFIG_SYSTEM_INCLUDE_PATH is not defined, and
the default list of library paths that are filtered out when
PKG_CONFIG_SYSTEM_LIBRARY_PATH is not defined, and
exit. Most other options and all command line arguments are ignored. This
option is only available if the preprocessor macro
PKGCONF_LITE was not defined during
compilation.--env=varname--env-only--with-path
and PKG_CONFIG_PATH only, ignoring
PKG_CONFIG_LIBDIR and the compiled-in default
directories.--errors-to-stdout--exact-version=version--existspkg-config to exit and report success or
failure before all arguments have been inspected.--fragment-filter=types--help--ignore-conflicts--keep-system-cflags,
--keep-system-libs--libs,
--libs-only-L,
--libs-only-l,
--libs-only-other-L) flags, or only the library
(-l) flags, or only the linker flags that are
neither library path nor library flags, respectively. These options imply
--print-errors.--list-allName property, a dash (‘-’), and the
Description property. This option implies
--print-errors. All command line arguments are
ignored.--list-package-names--list-all, but only
print the basename of each pc(5) file without the
extension, not the module name and the description. This option implies
--print-errors. All command line arguments are
ignored.--log-file=filePKG_CONFIG_LOG environment variable, and if that
is not provided either, this kind of logging is disabled.--max-version=version--maximum-traverse-depth=depthPKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH environment
variable and by the options --modversion,
--path, --print-provides,
--print-requires,
--print-requires-private,
--print-variables, and
--variable.--modversion--verbose option is
also specified, the name of the respective module
and a colon is printed before each version number. This option implies
--print-errors and
--maximum-traverse-depth=1 and overrides and
disables all --cflags and
--libs flags.--msvc-syntax--cflags,
--env, and --libs output.
This option is only available if the preprocessor macro
PKGCONF_LITE was not defined during
compilation.--no-cache--no-provides--no-uninstalled--path--prefix-variable=variable--print-errors--silence-errors.--print-providesName property, an
equal sign (‘=’), and the Version
property. If the module contains one or more
Provides properties, print additional lines in
dependency list format, one name per line, each name optionally followed
by an operator and a version. This option implies
--maximum-traverse-depth=1 and overrides and
disables all --cflags and
--libs flags.--print-requires,
--print-requires-privateRequires or
Requires.private properties, respectively, in
dependency list format to standard output. Both of these options imply
--maximum-traverse-depth=1 and override and
disable all --cflags and
--libs flags.--print-variables--print-errors and
--maximum-traverse-depth=1 and overrides and
disables all --cflags and
--libs flags.--pure--static flag and has no
effect if --shared is also specified.--relocate=path--static.--short-errors--silence-errors--debug,
--errors-to-stdout, and
--print-errors. This option is overridden and
disabled if the PKG_CONFIG_DEBUG_SPEW environment
variable is set.--simulatePKGCONF_LITE was not defined during
compilation.--solutionPKGCONF_LITE
was not defined during compilation.--static--shared.--uninstalled--validate
package ...--print-errors and
--errors-to-stdout.--variable=varname--maximum-traverse-depth=1 and overrides and
disables all --cflags and
--libs flags.--verbose--modversion is
also specified. It prints the name of the respective
module and a colon before each version number.--versionpkg-config program
to standard output and exit. Most other options and all command line
arguments are ignored.--with-path=pathPKG_CONFIG_PATH and
PKG_CONFIG_LIBDIR.CPATHPKG_CONFIG_SYSTEM_INCLUDE_PATH.CPLUS_INCLUDE_PATHPKG_CONFIG_SYSTEM_INCLUDE_PATH.C_INCLUDE_PATHPKG_CONFIG_SYSTEM_INCLUDE_PATH.DESTDIRPKG_CONFIG_SYSROOT_DIR, behave in the same way as
if PKG_CONFIG_FDO_SYSROOT_RULES is set. If
PKG_CONFIG_SYSROOT_DIR is not set or set to a
different value, DESTDIR is ignored.LIBRARY_PATHPKG_CONFIG_SYSTEM_LIBRARY_PATH.OBJC_INCLUDE_PATHPKG_CONFIG_SYSTEM_INCLUDE_PATH.PKG_CONFIG_ALLOW_SYSTEM_CFLAGS--keep-system-cflags option.PKG_CONFIG_ALLOW_SYSTEM_LIBS--keep-system-libs option.PKG_CONFIG_DEBUG_SPEW--silence-errors
option.PKG_CONFIG_DISABLE_UNINSTALLED--no-uninstalled flag.PKG_CONFIG_DONT_DEFINE_PREFIX--dont-define-prefix option.PKG_CONFIG_DONT_RELOCATE_PATHSPKG_CONFIG_FDO_SYSROOT_RULESPKG_CONFIG_IGNORE_CONFLICTSConflicts rules in modules. Has the
same effect as the --ignore-conflicts option.PKG_CONFIG_LIBDIRPKG_CONFIG_PATH, which enjoys higher priority. If
PKG_CONFIG_LIBDIR is not defined, the default list
compiled into the pkg-config program from the
PKG_DEFAULT_PATH preprocessor macro is appended
instead. If PKG_CONFIG_LIBDIR is defined but
empty, nothing is appended.PKG_CONFIG_LOG--log-file command line option, which overrides
this variable.PKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH--maximum-traverse-depth option, but
is overridden by the other options mentioned there.PKG_CONFIG_MSVC_SYNTAX--cflags,
--env, and --libs output.
This variable has the same effect as the
--msvc-syntax option. If the preprocessor macro
PKGCONF_LITE was defined during compilation, this
variable is ignored.PKG_CONFIG_PATH--with-path, if any, and unless
--env-only is specified, by appending either
PKG_CONFIG_LIBDIR or the compiled-in default
directories with lower priority.PKG_CONFIG_PURE_DEPGRAPH--pure
flag.PKG_CONFIG_RELOCATE_PATHS--define-prefix option.PKG_CONFIG_SYSROOT_DIRPKG_CONFIG_SYSTEM_INCLUDE_PATH--cflags and
--cflags-only-I options because they are
considered system include paths. If not defined, the default list compiled
into the pkg-config program from the
SYSTEM_INCLUDEDIR preprocessor macro is used
instead. This variable is a pkgconf-specific extension. Any directories
listed in the environment variables CPATH,
C_INCLUDE_PATH,
CPLUS_INCLUDE_PATH, and
OBJC_INCLUDE_PATH are also filtered out.PKG_CONFIG_SYSTEM_LIBRARY_PATH--libs and
--libs-only-L options because they are considered
system library paths. If not defined, the default list compiled into the
pkg-config program from the
SYSTEM_LIBDIR preprocessor macro is used instead.
This variable is a pkgconf-specific extension.PKG_CONFIG_TOP_BUILD_DIRThe pkg-config utility exits 0 on
success, and >0 if an error occurs.
Displaying the CFLAGS of a package:
$ pkg-config --cflags
foo-fPIC -I/usr/include/foo| June 7, 2025 | Debian |