PkgConf...Package(3)

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

πŸ’– PkgConf...Package(3) πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation, and it's all about PkgConfig::LibPkgConf::Package β€” the little object that holds literally everything you ever wanted to know about a package. pull up a chair, we're getting into it 🫢


✨ NAME ✨

PkgConfig::LibPkgConf::Package β€” it represents a package. that's it, that's the vibe πŸ’…


🌸 SYNOPSIS 🌸

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;

πŸ¦‹ DESCRIPTION πŸ¦‹

so the PkgConfig::LibPkgConf::Package object is where package information lives. and part of that package info is the compiler flags and the linker flags β€” iconic, honestly πŸ‘‘

you can grab those as strings with cflags and libs, or as a list with list_cflags and list_libs. now here's the tea: in the string form, escapes are retained. but in list form, the white space escapes get converted into spaces. 🫧

which means β€” and this is the important part, no cap β€” if you're using the string form of system/exec, you should use the string accessors. and if you're using the list form of system/exec, you should use the list accessors. match the energy, match the accessor ✨


πŸŽ€ ATTRIBUTES πŸŽ€

refcount

internal reference count used by pkgconf. it's giving behind-the-scenes main character πŸ”§

id

the id of the package.

filename

the filename of the .pc file.

realname

the real name for the package.

version

the version of the package.

description

description of the package.

url

URL for the package.

pc_filedir

TODO πŸ™ˆ (yes bestie, it literally just says TODO. we respect the honesty.)


πŸ’… METHODS πŸ’…

libs

library flags. this usually includes things like -L/foo/lib and -lfoo.

libs_static

static library flags.

cflags

compiler flags. this usually includes things like -I/foo/include and -DFOO=1.

cflags_static

static compiler flags.

list_libs

my @fragments = $package->list_libs;

library flags, but as a list of fragments β€” PkgConfig::LibPkgConf::Fragment. this is similar to the libs method above, but since it hands you a list instead of a single string, you can actually filter for specific flags. like:

# 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;

see? filtering. slay πŸ”₯

list_libs_static

my @fragments = $package->list_libs_static;

same energy as list_libs, but for the static libs flags.

list_cflags

my @fragments = $package->list_cflags;

compiler flags as a list of fragments β€” PkgConfig::LibPkgConf::Fragment. similar to the cflags method above, but again: list instead of single string, so you can 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;

periodt πŸ’œ

list_cflags_static

my @fragments = $package->list_cflags_static;

similar to list_cflags, but for the static compiler flags.

variable

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

look up the value for the given variable. returns the value if it's found β€” otherwise it returns undef (technically an empty list, bestie, don't @ me) 😭


🌈 SUPPORT 🌈

IRC: #native on irc.perl.org β€” come hang out, we don't bite 🫢

project GitHub tracker:

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

and if you wanna contribute? please open a pull request on GitHub:

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


⭐ SEE ALSO ⭐

for additional related modules, see PkgConfig::LibPkgConf πŸ‘‘


πŸ‘‘ 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. free as in freedom, bestie πŸ¦‹


okay and that's the whole page!! this one shipped as part of perl v5.42.0, dated 2025-07-25 β€” go forth and query your packages, you absolute icon πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from