PkgConf...::Client(3)

πŸ“¦
version 0.11 Β· 2 versions
, in fedora 43

πŸ’– PkgConf...::Client(3) πŸ’–

okay bestie, welcome to the User Contributed Perl Documentation for PkgConfig::LibPkgConf::Client β€” she's the whole reason your C code can find its lil libraries, and I'm gonna walk you through her like we're texting at 2am. no gatekeeping in this group chat πŸ’…


✨ NAME ✨

PkgConfig::LibPkgConf::Client β€” Query installed libraries for compiling and linking software πŸ¦‹

basically she goes "hey, you wanna build against libarchive? say less, here's your flags." icon behavior fr fr.


🌸 SYNOPSIS 🌸

use PkgConfig::LibPkgConf::Client;

my $client = PkgConfig::LibPkgConf::Client->new;
$client->env;

my $pkg = $client->find('libarchive');
my $cflags = $pkg->cflags;
my $libs = $pkg->libs;

see? four lines and you're compiling. she ate that. πŸŽ€


πŸ’« DESCRIPTION πŸ’«

so the tea is: PkgConfig::LibPkgConf::Client objects store all the necessary state for "libpkgconf", which means you can have multiple instances running in parallel without them fighting. no drama, no shared globals, just vibes. ✨


🧚 CONSTRUCTOR 🧚

πŸŽ€ new

my $client = PkgConfig::LibPkgConf::Client->new(%opts);
my $client = PkgConfig::LibPkgConf::Client->new(\%opts);

Creates an instance of PkgConfig::LibPkgConf::Client πŸ’–. Possible options include:

  • path β€” the search path to look for .pc files. You can hand her either a string with the appropriate path separator character, or a list reference. Heads up: this overrides the "pkgconf" compiled-in defaults and the environment variables for "PKG_CONFIG_PATH" or "PKG_CONFIG_LIBDIR". so like, she's not gonna check those if you tell her where to look. periodt.
  • filter_lib_dirs β€” list of directories to filter for libraries. This overrides the "pkgconf" compiled-in default and the environment variable for "PKG_CONFIG_SYSTEM_LIBRARY_PATH".
  • filter_include_dirs β€” list of directories to filter for include. This overrides the "pkgconf" compiled-in default and the environment variable for "PKG_CONFIG_SYSTEM_INCLUDE_PATH".

environment variables honored:

  • PKG_CONFIG_PATH
  • PKG_CONFIG_LIBDIR
  • PKG_CONFIG_SYSTEM_LIBRARY_PATH
  • PKG_CONFIG_SYSTEM_INCLUDE_PATH
  • PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
  • PKG_CONFIG_ALLOW_SYSTEM_LIBS

look at that list. she reads the room. she reads the env. πŸ‘‘


πŸ¦‹ ATTRIBUTES πŸ¦‹

⭐ path

my @path = $client->path;

The search path to look for .pc files. πŸ—ΊοΈ

⭐ filter_lib_dirs

my @dirs = $client->filter_lib_dirs;

List of directories to filter for libraries.

⭐ filter_include_dirs

my @dirs = $client->filter_include_dirs;

List of directories to filter for includes.

⭐ sysroot_dir

my $dir = $client->sysroot_dir;
$client->sysroot_dir($dir);

Get or set the sysroot directory. she's a getter and a setter, versatile queen. πŸ’…

⭐ buildroot_dir

my $dir = $client->buildroot_dir;
$client->buildroot_dir($dir);

Get or set the buildroot directory. same energy, different root. 🌈

⭐ maxdepth

my $int = $client->maxdepth;
$client->maxdepth($int);

Get or set the maximum dependency depth. it's 2000 by default, so like... she's willing to go deep bestie 😭


πŸ”₯ METHODS πŸ”₯

πŸ’œ env

my $client->env;

This method loads settings for the client object from the environment using the standard "pkg-config" or "pkgconf" environment variables. She honors this following list of environment variables:

  • PKG_CONFIG_LOG

ngl that's the only one listed here, so that's the one. πŸ“

πŸ’œ find

my $pkg = $client->find($package_name);

Searches the <.pc> file for the package with the given $package_name. If found, returns an instance of PkgConfig::LibPkgConf::Package. If not found, returns "undef". no package, no promises β€” always check before you go using it, bestie. πŸ™ˆ

πŸ’œ package_from_file

my $pkg = $client->package_from_file($filename);

Load the specific <.pc> file. just point her at the exact file and she'll do the rest. ✨

πŸ’œ scan_all

$client->scan_all(sub {
  my($client, $package) = @_;
  ...
  return $bool;
});

Iterates through all packages and calls the given subroutine reference for each package. $package isa PkgConfig::LibPkgConf::Package. The scan will continue so long as a non true value is returned (as $bool). so like β€” return something truthy and she keeps going, return falsy and she stops. yes that's backwards from how you'd expect, no I'm not gonna pretend it isn't, just read it twice. πŸ’€

πŸ’œ global

$client->global($key => $value);
my $value = $client->global($key);

Define or get the global variable. one method, two moods. πŸŽ€

πŸ’œ error

my $client->error($message);

Called when "libpkgconf" comes across a non-fatal error. By default the error is simply displayed as a warning using Carp. The intention of this method is: if you want to override that behavior, you will subclass PkgConfig::LibPkgConf::Client and implement your own version of the "error" method. so she's like, "here's the hook, customize me." main character energy. πŸ‘‘

πŸ’œ audit_set_log

$client->audit_set_log($filename, $mode);

Opens a file with the C "fopen" style $mode, and uses it for the audit log. The file is managed entirely by the client class and will be closed when the object falls out of scope. Examples:

$client->audit_set_log("audit.log", "a"); # append to existing file
$client->audit_set_log("audit2.log", "w"); # new or replace file

the way she handles the file lifecycle for you so you don't have to... obsessed. 🫢


🌈 SUPPORT 🌈

come hang out, we don't bite πŸ’œ


πŸŽ€ SEE ALSO πŸŽ€

For additional related modules, see PkgConfig::LibPkgConf β€” she's the whole fam, go say hi. πŸ¦‹


✨ AUTHOR ✨

Graham Ollis

For additional contributors see PkgConfig::LibPkgConf


This software is copyright (c) 2016 Graham Ollis.

This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

fr fr free software. slay. 🌸

okay that's the whole page bestie, you're officially pkgconf-pilled πŸ’…βœ¨

signing off from perl v5.42.0, dated 2025-07-25 β€” that's the version and date this page shipped with, no cap πŸŽ€

πŸ“¦ where this page comes from