Giter VIP home page Giter VIP logo

ffi-checklib's Introduction

FFI::CheckLib Build Status

Check that a library is available for FFI

SYNOPSIS

use FFI::CheckLib;

check_lib_or_exit( lib => 'jpeg', symbol => 'jinit_memory_mgr' );
check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] );

# or prompt for path to library and then:
print "where to find jpeg library: ";
my $path = <STDIN>;
check_lib_or_exit( lib => 'jpeg', libpath => $path );

DESCRIPTION

This module checks whether a particular dynamic library is available for FFI to use. It is modeled heavily on Devel::CheckLib, but will find dynamic libraries even when development packages are not installed. It also provides a find_lib function that will return the full path to the found dynamic library, which can be feed directly into FFI::Platypus or FFI::Raw.

Although intended mainly for FFI modules via FFI::Platypus and similar, this module does not actually use any FFI to do its detection and probing. This modules does not have any non-core dependencies on Perls 5.8-5.18. On Perl 5.20 and newer it has a configure, build and test dependency on Module::Build.

FUNCTIONS

All of these take the same named parameters and are exported by default.

find_lib

This will return a list of dynamic libraries, or empty list if none were found.

[version 0.05]

If called in scalar context it will return the first library found.

lib

Must be either a string with the name of a single library or a reference to an array of strings of library names. Depending on your platform, CheckLib will prepend lib or append .dll or .so when searching.

[version 0.11]

As a special case, if * is specified then any libs found will match.

libpath

A string or array of additional paths to search for libraries.

systempath

[version 0.11]

A string or array of system paths to search for instead of letting FFI::CheckLib determine the system path. You can set this to [] in order to not search any system paths.

symbol

A string or a list of symbol names that must be found.

verify

A code reference used to verify a library really is the one that you want. It should take two arguments, which is the name of the library and the full path to the library pathname. It should return true if it is acceptable, and false otherwise. You can use this in conjunction with FFI::Platypus to determine if it is going to meet your needs.
Example:

use FFI::CheckLib;
use FFI::Platypus;

my($lib) = find_lib(
  name => 'foo',
  verify => sub {
    my($name, $libpath) = @_;
    
    my $ffi = FFI::Platypus->new;
    $ffi->lib($libpath);
    
    my $f = $ffi->function('foo_version', [] => 'int');
    
    return $f->call() >= 500; # we accept version 500 or better
  },
);

recursive

[version 0.11]

Recursively search for libraries in any non-system paths (those provided via libpath above).

assert_lib

This behaves exactly the same as find_lib, except that instead of returning empty list of failure it throws an exception.

check_lib_or_exit

This behaves exactly the same as assert_lib, except that instead of dying, it warns (with exactly the same error message) and exists. This is intended for use in Makefile.PL or Build.PL

find_lib_or_exit

[version 0.05]

This behaves exactly the same as find_lib, except that if the library is not found, it will call exit with an appropriate diagnostic.

find_lib_or_die

[version 0.06]

This behaves exactly the same as find_lib, except that if the library is not found, it will die with an appropriate diagnostic.

check_lib

This behaves exactly the same as find_lib, except that it returns true (1) on finding the appropriate libraries or false (0) otherwise.

SEE ALSO

AUTHOR

Author: Graham Ollis [email protected]

Contributors:

Bakkiaraj Murugesan (bakkiaraj)

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 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.

ffi-checklib's People

Contributors

plicease avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.