PkgConfig::LibPkgConf::Client(3) User Contributed Perl Documentation PkgConfig::LibPkgConf::Client(3)

PkgConfig::LibPkgConf::Client - Query installed libraries for compiling and linking software

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;

The PkgConfig::LibPkgConf::Client objects store all necessary state for "libpkgconf" allowing for multiple instances to run in parallel.

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

Creates an instance of PkgConfig::LibPkgConf::Client. Possible options include:

The search path to look for ".pc" files. This may be specified either as a string with the appropriate path separator character, or as a list reference. This will override the "pkgconf" compiled in defaults and the environment variables for "PKG_CONFIG_PATH" or "PKG_CONFIG_LIBDIR".
List of directories to filter for libraries. This overrides the "pkgconf" compiled in default and environment variable for "PKG_CONFIG_SYSTEM_LIBRARY_PATH".
List of directories to filter for include. This overrides the "pkgconf" compiled in default and environment variable for "PKG_CONFIG_SYSTEM_INCLUDE_PATH".

environment variables honored:

my @path = $client->path;

The search path to look for ".pc" files.

my @dirs = $client->filter_lib_dirs;

List of directories to filter for libraries.

my @dirs = $client->filter_include_dirs;

List of directories to filter for includes.

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

Get or set the sysroot directory.

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

Get or set the buildroot directory.

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

Get or set the maximum dependency depth. This is 2000 by default.

my $client->env;

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

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".

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

Load the specific <.pc> file.

$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).

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

Define or get the global variable.

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.

$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

IRC #native on irc.perl.org

Project GitHub tracker:

https://github.com/plicease/PkgConfig-LibPkgConf/issues

If you want to contribute, please open a pull request on GitHub:

https://github.com/plicease/PkgConfig-LibPkgConf/pulls

For additional related modules, see PkgConfig::LibPkgConf

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.

2023-11-22 perl v5.38.0