# New Ticket Created by  Sylvain Colinet 
# Please include the string:  [perl #126645]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126645 >


Some distribution (debian) does not provide the libfoo.so symlink in the binary 
that provide a libfoo. In the case of debian it's provided by libfoo-dev.

I was not able to find what was a standard behavior for the unversioned .so file

But allowing to specify the api version could fix this so NC can find 
libfoo.so.apiversion

Here a quick patch that make it work.
It allows to write

sub foo is native('libfoo:42') ...



diff --git a/lib/NativeCall.pm b/lib/NativeCall.pm
index cc5d1d0..0702e17 100644
--- a/lib/NativeCall.pm
+++ b/lib/NativeCall.pm
@@ -162,7 +162,10 @@ sub guess_library_name($lib) {
     else {
         $libname = $lib;
     }
-
+    my $apiversion = '';
+    if ($libname.index(":")) {
+       ($libname, $apiversion) = $libname.split(':');
+    }
     if !$libname.DEFINITE { '' }
     elsif $libname ~~ /\.<.alpha>+$/ { $libname }
     elsif $libname ~~ /\.so(\.<.digit>+)+$/ { $libname }
@@ -175,14 +178,16 @@ sub guess_library_name($lib) {
             $libname ~ '.' ~ $*VM.config<nativecall.so>
         }
     }
+    # seem like this one is called for rakudo
     elsif $*VM.config<dll> :exists {
         my $ext = $*VM.config<dll>;
         $ext ~~ s/^.*\%s//;
-        "$libname$ext";
+        "$libname$ext" unless $apiversion;
+        "$libname$ext.$apiversion" if $apiversion and !$*DISTRO.is-win;
     }
     elsif $*DISTRO.is-win { "{$libname}.dll"; }
     # TODO: more extension guessing
-    else { "{$libname}.so"; }
+    else { "{$libname}.so"}
 }
 
 my %lib;

Reply via email to