PKG-CONFIG(1)

NAME
pkg-config - fetch metadata about installed software packages

SYNOPSIS
pkg-config [options] pkg-name [pkg-name ...]

DESCRIPTION
The pkg-config utility retrieves metadata about the installation of software packages. This metadata includes version, compiler and linker flags, and dependency information. It is inspired by, and intended to operate as a drop-in replacement to, the program of the same name available from freedesktop.org.

Metadata is stored in files named after the package they describe; the Yoyodyne package would likely be described by "yoyodyne.pc". Not all software packages provide pkg-config metadata. Libraries from base install their metadata in /usr/lib/pkgconfig; packages controlled by the ports(7) system store their metadata in /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig; the X Window System stores its metadata in /usr/X11R6/lib/pkgconfig and /usr/X11R6/share/pkgconfig. The pkg-config utility will search these locations by default.

Because pkg-config attempts to output the full set of compiler or linker flags required to use a package, it will also output the flags required for any prerequisite packages. If the "foo" package depends on the "bar" package, "pkg-config --cflags foo" might output something like "-I/usr/local/include/foo -I/usr/local/include/bar", even though the compiler flags for "bar" were not explicitly requested.

The options are as follows:

--atleast-pkgconfig-version version
    Exit with error if the version of pkg-config is not greater than or equal to the specified version.

--atleast-version version
    Exit with error if the specified package's version is not greater than or equal to the specified version.

--cflags
    Return all compiler flags required to compile against the package.

--cflags-only-I
    Return only the include path flags required to compile against the package.

--cflags-only-other
    Return all compiler flags, other than the include path flags, required to compile against the package.

--debug
    Enable internal development and debugging messages.

--errors-to-stdout
    Direct error messages to stdout rather than stderr.

--exact-version version
    Exit with error if the specified packages's version does not equal the specified version.

--exists
    Return true if all the specified packages are installed. This is the default operation.

--help | --usage
    Print a help message and exit.

--libs
    Return all linker flags required to link against the package.

--libs-only-L
    Return only the library path (-L/path/to/lib) flags required to link against the package.

--libs-only-l
    Return only the library (-lwhatever) flags required to link against the package.

--libs-only-other
    Return linker flags, other than the library and path flags, required to compile against the package.

--list-all
    List all installed packages and exit.

--max-version version
    Exit with error if the specified package's version is greater than the specified version.

--modversion
    Fetch package version. If no package is given, pkg-config returns its own version.

--print-errors
    Print error messages and exit with an error when errors occur. This is the default operation.

--print-provides
    Print all the modules the given package provides.

--print-requires
    Print all the modules the given package requires.

--print-requires-private
    Print all the modules the given package requires for static linking.

--silence-errors
    Do not print error messages, just exit with an error.

--static
    Return the compiler and/or linker flags required for static linking.

--uninstalled
    Allow packages not controlled by pkg-config to be used.

--validate
    Validate the package without processing its dependencies.

--variable name
    Fetch the value of the named variable.

--version
    Print version of pkg-config and exit.

ENVIRONMENT

PKG_CONFIG_DEBUG_SPEW
    If set, this will cause pkg-config to print various debugging information.

PKG_CONFIG_DISABLE_UNINSTALLED
    By default pkg-config prefers a package named "foo-uninstalled" over "foo" when the package "foo" is requested. This allows linking/compiling against uninstalled packages. Setting this flag disables the default behaviour.

PKG_CONFIG_LIBDIR
    This can be used to specify a colon-separated list of paths to search for package files. This will replace the default pkg-config search directory.

PKG_CONFIG_LOG
    This is used to specify a log file to which pkg-config will write the passed arguments.

PKG_CONFIG_PATH
    This can be used to specify a colon-separated list of paths to search for package files. If given, this list of paths is prepended to the standard search path.

PKG_CONFIG_SYSROOT_DIR
    This modifies -I and -L to use the target sysroot directory. Thus -I/usr/local/include will become -I/target/usr/local/include when PKG_CONFIG_SYSROOT_DIR is set to /target, which is useful when cross compiling packages that use pkg-config.

PKG_CONFIG_SYSTEM_INCLUDE_PATH
    When set to a list of paths, separated by :, these paths will be excluded from the output of include paths set with -I.

PKG_CONFIG_TOP_BUILD_DIR
    If set, pkg-config uses the specified value for pc_top_builddir instead of $(top_builddir).

PKG_CONFIG_$PACKAGE_$VARIABLE
    Override the $VARIABLE in $PACKAGE with the given value.

EXIT STATUS

SEE ALSO
pkg_info(1), ports(7)

HISTORY
The pkg-config utility first appeared in OpenBSD 4.1.

AUTHORS
-nosplit pkg-config was written by Chris Kuethe <ckuethe@openbsd.org> as a replacement for the original freedesktop.org pkg-config implementation. It was later extended and kept in sync (where relevant) with the original version by Marc Espie <espie@openbsd.org> and Jasper Lievisse Adriaanse <jasper@openbsd.org>.

CAVEATS
pkg-config is a re-implementation of the "original" freedesktop.org program. While it tries to be compatible, there are several design/functionality differences one should be aware of:

Conflicts
    It was decided not to support the Conflicts keyword as there is currently too little benefit from it in OpenBSD where the ports tree is supposed to prevent conflicts from arising in the first place. Lines with this keyword are not treated as errors, they are just ignored. And they are not taken into account when --print-errors is passed.

Cflags and -i
    The -i flag that can be encountered in Cflags is not treated differently from -I in this implementation.

Whitespace
    pkg-config does not go to great lengths to try to fix whitespace abuse. Whitespace in Libs and Cflags lines that are escaped using \ are treated correctly. But strings enclosed in quotation marks that contain whitespaces are not.