Generated by GPT-5-mini| pkg-config | |
|---|---|
| Name | pkg-config |
| Title | pkg-config |
| Developer | Multiple contributors |
| Released | 1997 |
| Operating system | Cross-platform |
| License | BSD-style / MIT / GPL variants |
pkg-config
pkg-config is a helper tool for managing compile and link flags for libraries used when building software. It automates retrieval of compiler options, linking flags, and dependency information for libraries such as GTK+, GLib, GStreamer, OpenSSL and FFmpeg, and is commonly integrated into build environments alongside tools like Autoconf, Automake, and CMake. Developers working on projects for platforms including Linux, FreeBSD, NetBSD, OpenBSD, macOS and Windows use pkg-config to simplify builds that involve libraries such as libxml2, SQLite, zlib and libpng.
pkg-config provides a uniform interface to query metadata about installed libraries, returning flags for compilers like GCC, Clang and MSVC and linkers used by projects from organizations such as The GNU Project, Debian, Fedora Project and Ubuntu. It reads metadata files installed by packages such as distributions from Red Hat, SUSE, Arch Linux and Gentoo, or by upstream projects including FFmpeg, OpenCV, Boost and Pango. By exposing variables like cflags and libs, pkg-config interoperates with build systems maintained by communities around Meson, Ninja, SCons, Bazel, and legacy systems like Make.
The tool emerged in the late 1990s as part of ecosystem efforts influenced by projects such as GNOME and X.Org to standardize how libraries publish compilation metadata. Early development intersected with work by contributors associated with The GNOME Project, Freedesktop.org and vendors like Red Hat, Inc. and X.Org Foundation. Over time, alternative implementations and forks appeared to address portability for systems maintained by organizations like Microsoft Corporation and Apple Inc., and to integrate with packaging systems such as RPM Package Manager, dpkg, Homebrew, MacPorts and pkgsrc. Discussions about licensing and portability have involved entities like Free Software Foundation and projects distributed under MIT License and BSD licenses.
Common invocation patterns mirror practices used by developers contributing to projects like LibreOffice, GIMP, Mozilla Firefox, Chromium and Thunderbird. Typical commands request cflags or libs for libraries such as libcurl, OpenSSL, libressl, libsndfile, PortAudio and PulseAudio. Options resemble conventions in tools from GNU Compiler Collection, LLVM Project and linkers used by Microsoft Visual C++. Command-line options used in CI/CD pipelines for projects hosted on services like GitHub, GitLab, Travis CI, CircleCI and Jenkins include flags to query --cflags, --libs, --modversion and --exists, often combined with shell constructs used in environments configured with systems from systemd or container runtimes like Docker and Kubernetes.
pkg-config reads .pc files that encode metadata and dependency graphs similar in spirit to metadata formats used by RPM Package Manager, Debian control files, Homebrew formulae, and manifest files used by Flatpak and Snapcraft. Each .pc file names variables and fields comparable to entries in manifests from Maven or NuGet but tailored to native compilation, specifying fields like Version, Requires, Libs, Libs.private and Cflags. Projects such as OpenSSL, GStreamer, GTK+, cairo and freetype install .pc files to locations governed by packaging policies from distributions like Fedora Project, Debian Project, Gentoo and Alpine Linux.
Integration patterns mirror practices used by large projects including KDE, GNOME, Blender, VLC media player, and QEMU. Build tools invoke pkg-config to obtain compile-time and link-time options, feeding results into toolchains such as GCC, Clang, Intel oneAPI, and Microsoft Visual Studio. Systems like Autotools (including Autoconf and Automake), CMake, Meson, SCons and Bazel include helper modules and wrappers to call pkg-config or emulate its behavior for reproducible builds in environments orchestrated by Jenkins, GitHub Actions and GitLab CI/CD.
Multiple implementations exist to support ecosystems maintained by organizations and projects such as Freedesktop.org, GNOME, X.Org Foundation, Homebrew, MacPorts, pkgsrc and various Linux distributions. There are reference implementations and compatible reimplementations that target portability for BSD descendants and Windows Subsystem for Linux environments. Compatibility concerns touch toolchains like GCC, Clang, linkers from GNU Binutils, and build frameworks used by LLVM Project and Microsoft Corporation tooling. Packaging and distribution of implementations are handled by maintainers in Debian, Fedora Project, Arch Linux, Gentoo and OpenBSD repositories.
Category:Build tools