Below is perl code which calls P5NCI::load_func to load function load_library having signature as int load_library(int dummy), hence third argument is passed as ii to P5NCI::load_func
my $library_path = P5NCI::find_lib( 'ESNMP.so' );
$library = P5NCI::load_lib( $library_path );
print "\nLibrary loaded";
print "\nlibrary_path".$library_path;
my $funcldlib = P5NCI::load_func( $library, 'load_library', 'ii');
This was working fine till perl-5.14, but later I used it for perl-5.26.3, but I am getting error as below:
Don't understand NCI signature 'ii'
I am thinking to use FFI platypus. I have successfully compiled Platypus using below steps:
perl -MCPAN -e shell
install FFI::Platypus
Wanted to know how can I use FFI::Platypus to achieve same purpose as mentioned in above code with P5NCI
Regards, Amit Mendhe
Here is an example of how you can use
FFI::Platypus
andFFI::CheckLib
to do the same as you did withP5NCI
:Note that this assumes that there is a file (the shared library) under the current directory called
lib/libESNMP.so
. This was the path I used for testing this script. I also assume that there is a function calledload_library()
defined in the shared library that takes an integer input argument and returns an integer.