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

PkgConfig::LibPkgConf::Package - Represents a package

use PkgConfig::LibPkgConf::Client;

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

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

# use with system in scalar form:
my $cflags = $pkg->cflags;
my $libs = $pkg->libs;
system "$cc $cflags foo.c";
system "$cc -o foo foo.o $libs";

# use with system in list form:
my @cflags = $pkg->list_cflags;
my @libs   = $pkg->list_libs;
system $cc, @cflags, 'foo.c';
system $cc, -p => 'foo', 'foo.o', @libs;

The PkgConfig::LibPkgConf::Package object stores package information. Part of the package information is the compiler and linker flags. This can be fetched as strings with "cflags" and "libs" and as a list with "list_cflags" and "list_libs". In the string form, escapes are retained, but in list form the white space escapes are converted into spaces. That means if you are using the string form of "system"/"exec" you should use the string accessors, and if you are using the list form of "system"/"exec" you should use the list accessors.

Internal reference count used by "pkgconf".

The id of the package.

The filename of the ".pc" file.

The real name for the package.

The version of the package.

Description of the package.

URL for the package.

TODO

Library flags. This usually includes things like "-L/foo/lib" and "-lfoo".

Static library flags.

Compiler flags. This usually includes things like "-I/foo/include" and "-DFOO=1".

Static compiler flags.

my @fragments = $package->list_libs;

Library flags as a list of fragments PkgConfig::LibPkgConf::Fragment. This is similar to the "libs" method above, but since it returns a list instead of a single string, it can be used to filter for specific flags. For example:

# equivalent to pkgconf --libs-only-L
my @lib_dirs = grep { $_->type eq 'L' } $package->list_libs;
# equivalent to pkgconf --libs-only-l
my @libs = grep { $_->type eq 'l' } $package->list_libs;

my @fragments = $package->list_libs_static;

Similar to "list_libs", but for the static libs flags.

my @fragments = $package->list_cflags;

Compiler flags as a list of fragments PkgConfig::LibPkgConf::Fragment. This is similar to the "cflags" method above, but since it returns a list instead of a single string, it can be used to filter for specific flags. For example:

# equivalent to pkgconf --cflags-only-I
my @include_dirs = grep { $_->type eq 'I' } $package->list_cflags;
# equivalent to pkgconf --cflags-only-other
my @other_cflags = grep { $_->type ne 'I' } $package->list_cflags;

my @fragments = $package->list_cflags_static;

Similar to "list_cflags", but for the static compiler flags.

my $value = $package->variable($key);

Look up the value for the given variable. Returns the value if found, otherwise it will return undef (technically empty list).

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