Rand Stats

NativeLibs

zef:raku-community-modules

Actions Status Actions Status

NAME

NativeLibs - Native libraries utilities

SYNOPSIS

# This also re-exports NativeCall :DEFAULTS for convenience
use NativeLibs;

# Load the needed library
my $Lib = INIT NativeLibs::Loader.load('libsomelib.so.4')
  orelse .fail;

sub some_native_func() is native {*} # Note no library needed

DESCRIPTION

The NativeLibs distribution provides a number of alternatives to loading binary libraries with NativeCall.

NativeLibs::Loader.load

This class method provides a Raku version of the raw binary library loading function as found in MoarVM.

NativeLibs::Searcher.at-runtime

If you need to check for a number of versions of the binary library you can do this with this class method:

use NativeLibs;

constant LIB = NativeLibs::Searcher.at-runtime(
  'mysqlclient', # The library short name
  'mysql_init',  # A 'well known symbol'
  16..20	     # A List of supported versions, a range in this example
);

sub mysql_get_client_info(--> Str) is export is native(LIB) {*}

AUTHORS

COPYRIGHT AND LICENSE

Copyright 2016 - 2021 by Salvador Ortiz

Copyright 2026 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.