简体   繁体   中英

UnsatisifedLinkedError : Could not locate stub library in jar file

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.

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 .

您需要文件的特定于平台的版本:libjffi-1.2.dylib参考问题,并尝试为您的平台版本找到一个相关的jar,其中将包含上述库文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM