ffi_scan#
List the shared libraries the dynamic linker already knows about.
Synopsis#
my $libs = Peta::FFI::scan;
print $libs->{"libm.so.6"}, "\n"; # /usr/lib/libm.so.6
my @names = grep { /^libssl/ } keys %$libs;
What you get back#
A hashref mapping each soname to the absolute path of its backing
file. The data comes from ldconfig -p, so it reflects the system
cache, not the full filesystem — a library not on the linker’s
search path will not appear here even if it exists on disk.
Use this to discover the right name to feed dlopen. When the same
soname appears more than once in the cache (e.g. 32-bit and 64-bit
copies), the first entry wins.
Edge cases#
ldconfignot installed or not on$PATH— returns an empty hashref rather than croaking; callers should treat an empty result as “no information available”.Duplicate sonames — only the first path is kept. If you need every match, read
ldconfig -pyourself.Non-Linux systems —
ldconfigis Linux-specific; on other platforms this function will typically return an empty hashref.