Skip to content

Commit 201878c

Browse files
committed
More documentation on library paths and names
1 parent d56e6b3 commit 201878c

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
@@ -646,18 +646,27 @@ to callbacks.
646646
647647
=head1 Library Paths and Names
648648
649-
=comment TODO
650-
651-
TBD more
652-
653-
The C<native> trait accepts the library name or the full path.
649+
The C<native> trait accepts the library name, the full path, or a subroutine
650+
returning either of the two. When using the library name, the name is assumed
651+
to be prepended with "lib" and appended with ".so" (or just appended with
652+
".dll" on Windows), and will be searched for in the paths in the
653+
LD_LIBRARY_PATH (PATH on Windows) environment variable.
654654
655+
=begin code :skip-test
655656
use NativeCall;
656657
constant LIBMYSQL = 'mysqlclient';
657658
constant LIBFOO = '/usr/lib/libfoo.so.1';
659+
sub LIBBAR {
660+
my $path = qx/pkg-config --libs libbar/.chomp;
661+
$path ~~ s/\/[[\w+]+ % \/]/\0\/bar/;
662+
$path
663+
}
658664
# and later
665+
659666
sub mysql_affected_rows returns int32 is native(LIBMYSQL) {*};
660667
sub bar is native(LIBFOO) {*}
668+
sub baz is native(LIBBAR) {*}
669+
=end code
661670
662671
You can also put an incomplete path like './foo' and NativeCall will automatically put
663672
the right extension according to the platform specification.

0 commit comments

Comments
 (0)