Quick hack for perl6 to check if a shared library is loadable
Perl 6
Switch branches/tags
Latest commit 458e956 Nov 4, 2017 @jonathanstowe jonathanstowe Add changes
Failed to load latest commit information.
lib Lose the "lib" prefix in tests Dec 24, 2015
t Lose the "lib" prefix in tests Dec 24, 2015
.gitignore Add .rev-deps to .gitignore Dec 21, 2015
.travis.yml Alter travis config to use zef Aug 2, 2017
Changes Add changes Nov 4, 2017
LICENCE rename LICENCE as en_GB May 30, 2016
META6.json Fix licence Apr 22, 2017
README.md No panda Aug 22, 2017



Determine whether a shared library is available to be loaded by Perl 6

Build Status


     use LibraryCheck;

     if !library-exists('sndfile', v1) {
         die "Cannot load sndfile";


This module provides a mechanism that will determine whether a named shared library is available and can be used by NativeCall.

It exports a single function 'library-exists' that returns a boolean to indicate whether the named shared library can be loaded and used.

This can be used in a builder to determine whether a module has a chance of working (and possibly aborting the build,) or in tests to cause the tests that may rely on a shared library to be skipped, but other use-cases are possible.

 use LibraryCheck;

 if !library-exists('sndfile', v1) {
     die "Cannot load sndfile";

The case above can be more simply written as:

 library-check('sndfile',v1, :exception);

Which will throw an X::NoLibrary exception rather than return False.

The implementation is somewhat of a hack currently and definitely shouldn't be taken as an example of nice Perl 6 code.


Assuming you have a working Rakudo perl6 installation you should be able to install this with zef :

# From the source directory

zef install .

# Remote installation

zef install LibraryCheck

Other install mechanisms may be become available in the future.


Suggestions/patches are welcomed via github at https://github.com/jonathanstowe/LibraryCheck/issues

I'd be particularly interested in having it work properly on all the platforms that rakudo will work on.


Please see the LICENCEi file in the distribution

© Jonathan Stowe 2015, 2016, 2017