Imager::Probe(3pm)

🌸 NAME 🌸

Imager::Probe β€” a hot needle of inquiry for libraries πŸ’…

okay so bestie, this is the module that goes poking around your system like "hey... do you have this library?? no?? what about this one??" β€” a literal detective for C libraries, and honestly? icon behavior.


✨ SYNOPSIS ✨

  require Imager::Probe;

  my %probe =
    (
     # short name of what we're looking for (displayed to user)
     name => "FOO",
     # pkg-config lookup
     pkg => [ qw/name1 name2 name3/ ],
     # perl subs that probe for the library
     code => [ \&foo_probe1, \&foo_probe2 ],
     # or just: code => \&foo_probe,
     inccheck => sub { ... },
     libcheck => sub { ... },
     # search for this library if libcheck not supplied
     libbase => "foo",
     # library link time options, uses libbase to build options otherwise
     libopts => "-lfoo",
     # C code to check the library is sane
     testcode => "...",
     # header files needed
     testcodeheaders => [ "stdio.h", "foo.h" ],
    );
  my $result = Imager::Probe->probe(\%probe)
    or print "Foo library not found: ",Imager::Probe->error;

like, you hand it a big ol' hash of "here's how to look for this thing" and it comes back with either a hit or a very polite undef. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So. This module does all the probes that used to be hidden inside Imager's Makefile.PL β€” they got yanked out into their own whole thing so that the file format libraries can be externalized. main character extraction, fr fr. πŸ‘‘

The return value is either nothing if the probe fails (😭), or a hash containing:

  • "INC" β€” the -I and other C options
  • "LIBS" β€” the -L, -l and other link-time options
  • "DEFINE" β€” the -D options, if any

now for the fun part β€” the possible values for the hash you supply to the probe() method, one by one, no skips:

  • "pkg" β€” an array of pkg-config names to probe for. And here's the tea β˜•: if the pkg-config checks pass, "inccheck" and "libcheck" aren't used. like, they don't even get a turn.
  • "inccheck" β€” a code reference that checks if the supplied include directory contains the required header files. πŸ”
  • "libcheck" β€” a code reference that checks if the supplied library directory contains the required library files. > heads up bestie: the Makefile.PL version of this was supplied all of the library file names instead. <italic>(yes, it changed, we know, it's fine)</italic> β€” also, "libcheck" can be an arrayref of library check code references, and all of them must find a match for the library to be considered "found". all of them. no partial credit. πŸ’€
  • "libbase" β€” if "inccheck" is supplied but "libcheck" isn't, then a "libcheck" that checks for "lib"libbase$Config{_a} and "lib"libbase.$Config{so} is created. and if "libopts" isn't supplied, then that can be synthesized as -llibbase. "libbase" can also be an arrayref of library base names to search for, in which case all of the libraries mentioned must be found for the probe to succeed. teamwork makes the dream work ✨
  • "libopts" β€” if the libraries are found via "inccheck"/"libcheck", these are the -l options to supply during the link phase. πŸ”—
  • "code" β€” a code reference to perform custom checks. it returns the probe result directly, no middleman. can also be an array ref of functions to call. πŸ“ž
  • "testcode" β€” test C code that is run with Devel::CheckLib. > also you need to set "testcodeheaders", don't forget, it's not optional 😀
  • "testcodeprologue" β€” C code to insert between the headers and the main function. a lil' sandwich filler πŸ₯ͺ
  • "incpath" β€” $Config{path_sep} separated list of header file directories to check, or a reference to an array of such.
  • "libpath" β€” $Config{path_sep} separated list of library file directories to check, or a reference to an array of such.
  • "alternatives" β€” an optional array reference of alternate configurations (as hash references) to test if the primary configuration isn't successful. 😬 each alternative should include an "altname" key describing the alternative. and here's the clutch detail: any key not mentioned in an alternative defaults to the value from the main configuration. so you only override what you gotta override. πŸŽ€

πŸ’œ AUTHOR πŸ’œ

Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson


and that's the whole vibe, bestie 🌈 β€” brought to you by perl v5.42.3, dated 2026-08-19, from the User Contributed Perl Documentation collection, and obviously it's the <rainbow>Imager::Probe(3pm)</rainbow> page πŸ’– go probe something, slay, periodt. πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from