2

I am trying to use this jnr-jffi library. It appears to have a dependency on jffi so I have also built that and included in my libs folder.

My code to load the native code is as follows:

MATH_LIB = LibraryLoader.create(MathLib.class).load("math");

MATH_LIB.Multiply(1, 2);

And I get the following error:

java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: could not locate stub library in jar file.  Tried [jni/Darwin/libjffi-1.2.dylib, /jni/Darwin/libjffi-1.2.dylib]

For what it's worth, I did include a folder jni that appears to contain a bunch of native libraries for various platforms.

How I can proceed to load my native code using this library.

Please note that I have tried adding various paths when launching my project and also adding the libraries to various locations on my machine, with no success.

That would mean I need to figure out how to debug further into this? Any advice is welcome.

jim
  • 8,670
  • 15
  • 78
  • 149

2 Answers2

0

It would be easiest to use maven when using JNR. Maven will automatically resolve all the needed dependencies.

You can just add this to your pom.xml:

<dependency>
     <groupId>com.github.jnr</groupId>
     <artifactId>jnr-ffi</artifactId>
     <version>2.0.9</version>
</dependency>

Or find a more up-to-date version here.

Jorn Vernee
  • 31,735
  • 4
  • 76
  • 93
0

You need the platform specific version of the file: libjffi-1.2.dylib Refer to this issue & try to find a relevant jar for your platform version which would contain the above library file.

Akash Mishra
  • 682
  • 1
  • 5
  • 13