PPKG-CONFIG(1p)
π PPKG-CONFIG π
okay bestie, you've landed on the 1p manual page and honestly? iconic. grab a boba, we're getting into it. π§β¨
πΈ NAME πΈ
PkgConfig β a Pure-Perl, Core-Only replacement for pkg-config. no cap, it literally just does the thing without dragging glib along for the ride. π
π¦ 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, but likeβ¦ don't, bestie, not recommended if your system already has a native pkg-config. π
now compare that to the O.G.:
$ 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. periodt.
important vibe check though: this is not a description of what pkg-config is even for. it's a description of the differences between the C version and the Perl one. so if you came here looking for "what does pkg-config do," wrong page bestie, but you're still welcome. π
so 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. slay.
the main supported options are the common ones you'd actually use: --libs, --cflags, --static, --exists and --modversion. the greatest hits, fr fr. π₯
π SCRIPT OPTIONS π
USAGE
<packagename1 pkgname2..> [ --options ]
ARGUMENTS
by default, a library name must be supplied β unless one of --version or --real-version is specified. so like, either give it a package or give it a version flag, it's not gonna guess. π
the output should normally be suitable for passing to your favorite compiler. yes, your favorite. we don't judge here. π
--libsβ (also) print linker flags. Dependencies are traversed in order, and top-level dependencies will show up earlier in the command line than bottom-level dependencies. so the order is giving organized, we love to see it.--libs-only-Lβ prints just the-L/-Rpart of--libs. it defines the library search path but without the libraries to link with. it's giving "here's the neighborhood, not the house." ποΈ--libs-only-lβ prints the-lpart of--libs. (that's lowercasel, don't get it twisted with the one above. π)--libs-only-otherβ prints the part of--libsnot covered by--libs-only-Land--libs-only-l, such as--pthread. the leftovers, but make it useful.--list-allβ list all known packages. a whole catalog, bestie. π--cflagsβ (also) print compiler and C preprocessor flags.--cflags-only-Iβ prints the-Ipart of--cflags. include paths only, no extras.--cflags-only-otherβ prints the parts of--cflagsnot covered by--cflags-only-I. the "everything else" bucket. πͺ£--modversionβ print the version of a given package. just the number, ma'am.--staticβ use extra dependencies and libraries if you're linking against a static version of the requested library. static linking era, we're committed. π--existsβ return success (0) if the package exists in the search path. the quiet "does this even exist" check.--with-path=PATHβ prependPATHto the list of search paths containing.pcfiles. and yes, this option can be specified multiple times with different paths, and they'll all be added. stacking paths like it's a fit check. β¨--env-onlyβ using this option, only paths specified inPKG_CONFIG_PATHare recognized, and any hard-coded defaults are ignored. strict mode, basically.--guess-pathsβ invokegccandldto determine default linker and include paths. default paths will then be excluded from explicit-Land-Iflags. it's giving detective energy. π--define-variable=VARIABLE=VALUEβ define a variable, overriding any such variable definition in the.pcfile, and allowing your value to interpolate with subsequent uses. you're the author now. βοΈ--variable=VARIABLEβ this returns the value of a variable defined in a package's.pcfile. just ask, it'll tell you. π«Ά--print-variablesβ print all defined variables found in the.pcfiles. the whole variable roster, no secrets.--versionβ the target version ofpkg-configemulated by this script. (emulated, bestie. we're doing an impression.)--real-versionβ the actual version of this script. the real one, no filter. π―--debugβ print debugging information. for when you need the lore. π--silence-errorsβ turn off errors. this is the default for non-libs/cflag/modversion arguments. shhh. π€«--print-errorsβ print errors toSTDERR, and takes precedence over--silence-errors. so if both are on, this one wins. periodt.--short-errorsβ ignored, but recognized for compatibility. it's there, it's just not doing anything. an icon that simply exists. π--errors-to-stdoutβ print errors toSTDOUT, and takes precedence over--print-errors. the final boss of error destinations. π
π± 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_PATHHKEY_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 the author has yet to find a working version that actually implements this feature. so likeβ¦ it's real in the docs, bestie. π«
π§ 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. flexible, we love her. π
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 already know the full path of the exact.pcfile that you want. no searching required, you already found it. π―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 because 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. low effort, high reward. β¨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. if it's here, something went sideways. π¬$o->pkg_existsβ boolean value, true if the package exists. just a yes/no vibe.$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. so if that's not your setupβ¦ yeah. π
π οΈ 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. pick your fighter. π₯
--script ppkg-configβ this is the default and works on all platforms. the safe, universal choice. π--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. (imagine trying to run something and it just opens Notepad. π)--script pkg-configβ this is the default name of the realpkg-config, and so you have to specifically enable it if you want it. opt-in only, bestie.--script noneβ don't install any scripts. minimalism. π
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. set it once, and future-you says thank you. π
πΈ CAVEATS πΈ
on Strawberry Perl, ppkg-config acts like Strawberry is the system. so basically:
- 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). read that twice, bestie, it matters. π
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 that of pkg-config. from the author's own observation, it seems this module does a better job, but they might be wrong. humble queen behavior honestly. π
unlike pkg-config, the script's --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). so yeah, --exists here is doing extra work. overachiever energy. π
β¨ SEE ALSO β¨
okay bestie, here's the whole squad of other implementations and friends π go look at them if you're nosy (respectfully):
pkg-configβhttp://www.freedesktop.org/wiki/Software/pkg-configβ the OG, the original C implementation. the blueprint, the blueprint-iest blueprint πpkgconfβhttps://github.com/pkgconf/pkgconfβ an alternative C implementation. a whole other take, same energy π₯PkgConfig::LibPkgConfβ Perl bindings forlibpkgconf, which is literally the exact same library thatpkgconfis built on. same engine, Perl-shaped steering wheel πβ¨ExtUtils::PkgConfigβ a wrapper around thepkg-configbinary that you can drop into yourMakefile.PLorBuild.PL. it's giving "perl build system but make it pkg-config aware" π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. π for the ruby girliespykg-configβhttps://pypi.python.org/pypi/pykg-config/1.2.0β a Python implementation. slithering in with the snake energy π
π AUTHOR π
the credits, because we give credit around here:
- Original Author: M. Nunberg
- Current maintainer: Graham Ollis
<plicease@cpan.org>
Other contributors include, and we are obsessed with every single one of them:
- Vladimir Timofeev (vovkasm)
- kmx
- Sanel Zukan
- Breno G. de Oliveira (garu)
- Gregor Herrmann
- Ilya Pavlov (ILUX, Ilya33)
- Shawn Laffan (SLAFFAN, shawnlaffan)
- Ari Jolma (AJOLMA)
no cap, that's a stacked roster πΈπ«Ά
π 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 like, go off, remix it, share it, whatever β just keep it under those same terms, periodt π
and that's the whole page bestie!! you read all of it, main character behavior fr fr ππ
this lil edition is from perl v5.40.1, dated 2025-04-17, and it's the PPKG-CONFIG(1p) manual β mwah, go forth and pkg-config responsibly π
β¨π
π¦ where this page comes from
- debian trixie: libpkgconfig-perl 0.26026-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpkgconfig-perl 0.26026-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpkgconfig-perl 0.26026-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms