Skip to content

Commit 8994f4f

Browse files
authored
Merge pull request #2140 from Kaiepi/nativecall
More documentation on library paths and names This closes #1513
2 parents f3052b8 + 201878c commit 8994f4f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

doc/Language/nativecall.pod6

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,27 @@ to callbacks.
659659
660660
=head1 Library Paths and Names
661661
662-
=comment TODO
663-
664-
TBD more
665-
666-
The C<native> trait accepts the library name or the full path.
662+
The C<native> trait accepts the library name, the full path, or a subroutine
663+
returning either of the two. When using the library name, the name is assumed
664+
to be prepended with "lib" and appended with ".so" (or just appended with
665+
".dll" on Windows), and will be searched for in the paths in the
666+
LD_LIBRARY_PATH (PATH on Windows) environment variable.
667667
668+
=begin code :skip-test
668669
use NativeCall;
669670
constant LIBMYSQL = 'mysqlclient';
670671
constant LIBFOO = '/usr/lib/libfoo.so.1';
672+
sub LIBBAR {
673+
my $path = qx/pkg-config --libs libbar/.chomp;
674+
$path ~~ s/\/[[\w+]+ % \/]/\0\/bar/;
675+
$path
676+
}
671677
# and later
678+
672679
sub mysql_affected_rows returns int32 is native(LIBMYSQL) {*};
673680
sub bar is native(LIBFOO) {*}
681+
sub baz is native(LIBBAR) {*}
682+
=end code
674683
675684
You can also put an incomplete path like './foo' and NativeCall will automatically put
676685
the right extension according to the platform specification.

0 commit comments

Comments
 (0)