PKG-CONFIG(1)
๐ NAME ๐
Okay bestie, welcome to the PKG-CONFIG(1) manual page. This is PkgConfig โ literally a Pure-Perl Core-Only replacement for pkg-config. No cap. It's giving "same job, but Perl-flavored" and we're obsessed. ๐
โจ SYNOPSIS โจ
๐ As a replacement for pkg-config
$ ppkg-config --libs --cflags --static gio-2.0
#outputs (lines artificially broken up for readability):
# -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
# -pthread -lgio-2.0 -lz -lresolv -lgobject-2.0
# -lgmodule-2.0 -ldl -lgthread-2.0 -pthread -lrt -lglib-2.0
So pkg-config.pl can be used as an alias for ppkg-config on platforms that support it. It can also be installed as pkg-config โ though this is not recommended if your system already has a native pkg-config. Respectfully, don't start drama with your system's real pkg-config. ๐
Compare to:
$ pkg-config --libs --cflags --static gio-2.0
#outputs ( "" ):
# -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
# -pthread -lgio-2.0 -lz -lresolv -lgobject-2.0 -lgmodule-2.0
# -ldl -lgthread-2.0 -lrt -lglib-2.0
๐ From another Perl module
use PkgConfig;
my $o = PkgConfig->find('gio');
if($o->errmsg) {
#handle error
} else {
my $prefix = $o->get_var('prefix');
my @cflags = $o->get_cflags;
my @ldflags = $o->get_ldflags;
}
๐ธ DESCRIPTION ๐ธ
PkgConfig provides a pure-perl, core-only replacement for the pkg-config utility. It's the "I can do it myself" main character of build-flag lookup. ๐โโ๏ธ
Important vibe check: this is not a description of the uses of pkg-config. It's a description of the differences between the C version and the Perl one. So don't come here looking for "what is pkg-config even for" โ this page is the comparison arc. โจ
While pkg-config is a compiled binary linked with glib, the pure-perl version has no such requirement, and will run wherever Perl ( >= 5.6 ) does. Lowkey iconic. ๐ซถ
The main supported options are the common --libs, --cflags, --static, --exists and --modversion.
๐ SCRIPT OPTIONS ๐
๐ USAGE
<packagename1 pkgname2..> [ --options ]
๐งพ ARGUMENTS
By default, a library name must be supplied unless one of --version, or --real-version is specified.
The output should normally be suitable for passing to your favorite compiler. Yes bestie, we're feeding the compiler. ๐
--libsโ Also print linker flags. Dependencies are traversed in order. Top-level dependencies will appear earlier in the command line than bottom-level dependencies.--libs-only-Lโ Prints the-L/-Rpart of--libs. It defines library search path but without libraries to link with.--libs-only-lโ Prints the-lpart of--libs.--libs-only-otherโ Prints the part of--libsnot covered by--libs-only-Land--libs-only-l, such as--pthread.--list-allโ List all known packages.--cflagsโ Also print compiler and C preprocessor flags.--cflags-only-Iโ Prints the-Ipart of--cflags.--cflags-only-otherโ Prints the parts of--cflagsnot covered by--cflags-only-I.--modversionโ Print the version of a given package.--staticโ Use extra dependencies and libraries if linking against a static version of the requested library.--existsโ Return success (0) if the package exists in the search path.--with-path=PATHโ PrependPATHto the list of search paths containing.pcfiles. This option can be specified multiple times with different paths, and they will all be added.--env-onlyโ Using this option, only paths specified inPKG_CONFIG_PATHare recognized and any hard-coded defaults are ignored.--guess-pathsโ Invokegccandldto determine default linker and include paths. Default paths will be excluded from explicit-Land-Iflags.--define-variable=VARIABLE=VALUEโ Define a variable, overriding any such variable definition in the.pcfile, and allowing your value to interpolate with subsequent uses.--variable=VARIABLEโ This returns the value of a variable defined in a package's.pcfile.--print-variablesโ Print all defined variables found in the.pcfiles.--versionโ The target version ofpkg-configemulated by this script.--real-versionโ The actual version of this script.--debugโ Print debugging information.--silence-errorsโ Turn off errors. This is the default fornon-libs/cflag/modversionarguments.--print-errorsโ Print errors toSTDERRand takes precedence over--silence-errors.--short-errorsโ Ignored, but recognized for compatibility.--errors-to-stdoutโ Print errors toSTDOUTand takes precedence over--print-errors.
๐ ENVIRONMENT
The PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR variables are honored and used as a colon-delimited (semicolon-delimited on Windows) list of directories that contain .pc files.
Other environment variables recognized by both pkg-config and PkgConfig include:
PKG_CONFIG_ALLOW_SYSTEM_CFLAGSPKG_CONFIG_ALLOW_SYSTEM_LIBS
If Win32API::Registry is installed, on Windows (but not Cygwin) PkgConfig will also consult these registry keys. The names are ignored, but the values are paths containing .pc files.
HKEY_CURRENT_USER\Software\pkgconfig\PKG_CONFIG_PATH
HKEY_LOCAL_MACHINE\Software\pkgconfig\PKG_CONFIG_PATH
โ ๏ธ Registry support should be considered somewhat experimental, subject to change in the future, though not without good reason. The rationale for this caveat is that this feature is documented in several places, but I have yet to find a working version that implements this feature.
๐งฉ MODULE OPTIONS ๐งฉ
๐ PkgConfig->find
my $result = PkgConfig->find($library, %options);
Find a library and return a result object. $library can be either a single name of a library, or a reference to an array of library names.
The options are in the form of hash keys and values, and the following are recognized:
search_path,search_path_overrideโ Prepend search paths in addition to the paths specified in$ENV{PKG_CONFIG_PATH}. The value is an array reference. The_overridevariant ignores defaults (likePKG_CONFIG_PATH).file_pathโ Specifies the full path of the.pcfile that you wish to load. It does not need to be in the search path (although any dependencies will need to be). Useful if you know the full path of the exact.pcfile that you want.exclude_cflags,exclude_ldflags,exclude_cflags_override,exclude_ldflags_overrideโ Some.pcfiles specify default compiler and linker search paths, e.g.-I/usr/include -L/usr/lib. Specifying them on the command line can be problematic as it drastically changes the search order. The above options will either append or replace the options which are excluded and filtered. The default excluded linker and compiler options can be obtained via@PkgConfig::DEFAULT_EXCLUDE_LFLAGSand@PkgConfig::DEFAULT_EXCLUDE_CFLAGS, respectively.staticโ Also specify static libraries.no_recurseโ Do not recurse dependencies. This is useful for just doing version checks.VARSโ Define a hashref of variables to override any variable definitions within the.pcfiles. This is equivalent to the--define-variablecommand-line option.
A PkgConfig object is returned and may be queried about the results:
$o->errmsgโ An error message, if any. This is a string and indicates an error.$o->pkg_existsโ Boolean value, true if the package exists.$o->pkg_versionโ The version of the package.$o->get_cflags,$o->get_ldflagsโ Returns compiler and linker flags, respectively. In list context, these methods return a list with each argument split on unescaped spaces. In list context returns a list of compiler and linker flags, respectively. In scalar context returns a string of compiler and linker flags with spaces and quotes escaped correctly.$o->get_var($name)โ Get the variable with the given name.
๐ฎ PkgConfig->Guess
This is a class method, and will replace the hard-coded default linker and include paths with those discovered by invoking ld(1) and cpp(1).
Currently this only works with GCC-supplied ld and GNU ld.
๐ฆ INSTALL ๐ฆ
The Makefile.PL that comes with PkgConfig can take one or more --script options to change the name of the script or scripts that are installed.
--script ppkg-configโ This is the default and works on all platforms.--script pkg-config.plโ This is installed by default on all platforms except for Windows, where the.plmay confuse the shell and cause the script to be opened in a text editor.--script pkg-configโ This is the default name of the realpkg-configand so you have to specifically enable it if you want it.--script noneโ Don't install any scripts.
Example, install all script names:
% perl Makefile.PL --script ppkg-config --script pkg-config.pl --script pkg-config
Example, don't install any scripts:
% perl Makefile.PL --script none
You can also set the environment variable PERL_PKG_CONFIG_SCRIPTS to the desired --script value (separating each script name with a comma ,) to ensure that upgrades of PkgConfig do the same.
โ ๏ธ CAVEATS โ ๏ธ
On Strawberry Perl ppkg-config acts like Strawberry is the system. This means that:
- The
.pcfiles that are bundled with Strawberry are searched by default. - The Strawberry include and lib directories are used to compute the exclusion lists.
As of Strawberry 5.20.0.1 PkgConfig is bundled with Strawberry and pkg-config is installed by default (in addition to ppkg-config, though the ppkg-config alias is NOT bundled with Strawberry itself).
For details on how to patch the .pc files bundled with older Strawberries, see the README.win32 that comes with this Distribution.
๐ BUGS ๐
The order of the flags is not exactly matching to that of pkg-config. From my own observation, it seems this module does a better job, but I might be wrong. ๐
Unlike pkg-config, the scripts --exists function will return nonzero if a package or any of its dependencies are missing. This differs from the behavior of pkg-config which will just check for the definition of the package itself (without dependencies).
๐ SEE ALSO ๐
okay bestie, if you wanna go down the rabbit hole, here's the whole little ecosystem โ no gatekeeping, we love that for us ๐
pkg-configโ <http://www.freedesktop.org/wiki/Software/pkg-config> โ the O.G. C implementation, the blueprint, the icon โจpkgconfโ <https://github.com/pkgconf/pkgconf> โ an alternative C implementation, lowkey doing its own thing but make it C ๐PkgConfig::LibPkgConfโ Perl bindings forlibpkgconf, aka the exact same library thatpkgconfis built on ๐ExtUtils::PkgConfigโ a wrapper around thepkg-configbinary that you can use in yourMakefile.PLorBuild.PL๐- <http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/pkg-config/> โ another perl implementation of pkg-config, yes another one, we stay fed ๐
pkg-configโ <https://github.com/ruby-gnome2/pkg-config> โ a pure Ruby implementation, slay in a whole different language ๐pykg-configโ <https://pypi.python.org/pypi/pykg-config/1.2.0> โ a Python implementation, because of course Python showed up too ๐
๐ AUTHOR ๐
Original Author: M. Nunberg
Current maintainer: Graham Ollis <plicease@cpan.org> โ say hi, be normal, do not spam the inbox bestie ๐ญ
Other contributors include:
- Vladimir Timofeev (vovkasm)
- kmx
- Sanel Zukan
- Breno G. de Oliveira (garu)
- Gregor Herrmann
- Ilya Pavlov (ILUX, Ilya33)
- Shawn Laffan (SLAFFAN, shawnlaffan)
- Ari Jolma (AJOLMA)
literal legends, every single one ๐ซถโจ
๐ COPYRIGHT AND LICENSE ๐
Copyright (C) 2012 M. Nunberg
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
so yes, it's free software, and the license vibe is โsame terms as the Perl 5 programming language system itselfโ โ copy that exactly, no freestyle ๐
signing off from the perl v5.42.0 era, dated 2025-12-14, this was your PKG-CONFIG(1) bestie โ mwah, drink water, and may your flags always parse ๐ธ๐
๐ฆ where this page comes from
- arch rolling: perl-pkgconfig 0.26026-3 ยท PerlArtistic
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms