13 Dec 2019 15:22:59 UTC
- Distribution: FFI
- Module version: 1.15
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Testers (300 / 0 / 0)
- KwaliteeBus factor: 2
- 79.75% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (21.21KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:PLICEASE 🦖🦜Graham Ollis🦃🦕
- SEE ALSO
- COPYRIGHT AND LICENSE
FFI::Library - Perl Access to Dynamically Loaded Libraries
# call function from arbitrary dynamic library use FFI::Library; $lib = FFI::Library->new("mylib"); $fn = $lib->function("fn", "signature"); $ret = $fn->(...); # call function from libc $clib_file = ($^O eq "MSWin32") ? "MSVCRT40.DLL" : "-lc"; $clib = FFI::Library->new($clib_file); $strlen = $clib->function("strlen", "cIp"); $n = $strlen->($my_string);
NOTE: Newer and better maintained FFI modules such as FFI::Platypus provide more functionality and so it is strongly recommend that you use one of them for new projects and even consider migrating to one of them for existing projects.
This module provides access from Perl to functions exported from dynamically linked libraries. Functions are described by
signatures, for details of which see the FFI module's documentation.
my $lib = FFI::Library->new($libname);
Creates an instance of
my $address = $lib->address($function_name);
Returns the symbol of the given function. Returns
undefif the symbol is not found.
my $sub = $lib->function($function_name, $signature);
Creates a code-reference like object which you can call.
$clib_file = ($^O eq "MSWin32") ? "MSVCRT40.DLL" : "-lc"; $clib = FFI::Library->new($clib_file); $strlen = $clib->function("strlen", "cIp"); $n = $strlen->($my_string);
Please open any support tickets with this project's GitHub repository here:
Low level interface to ffcall that this module is based on
Portable functions for finding libraries.
Platypus is another FFI interface based on libffi. It has a more extensive feature set, and libffi has a less restrictive license.
Original author: Paul Moore <firstname.lastname@example.org>
Current maintainer: Graham Ollis <email@example.com>
Anatoly Vorobey <firstname.lastname@example.org>
Gaal Yahas <email@example.com>
Mitchell Charity <firstname.lastname@example.org>
Reini Urban <<RURBAN@cpan.org>
This software is copyright (c) 2016-2018 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.