简体   繁体   English

尝试在Mac OS X上加载JNA库时出现“无法加载库:在资源路径中找不到JNA本机支持”

[英]“Unable to load library: JNA native support not found in resource path” on trying to load JNA library on Mac OS X

I have a JNA library stub like this: 我有一个像这样的JNA库存根:

public interface FREngine extends Library {
    NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance("FREngine");
    FREngine INSTANCE = (FREngine) Native.loadLibrary("FREngine", FREngine.class);
}

If I try to use this library in any way, I get a really confusing error: 如果我尝试以任何方式使用此库,则会收到一个真正令人困惑的错误:

java.lang.UnsatisfiedLinkError: Unable to load library 'FREngine': 
    JNA native support (darwin/libFREngine.jnilib) not found in resource path 
    (...entire classpath here...)

Why this is confusing to me: 为什么这让我感到困惑:

  • .jnilib is the file extension for JNI libraries. .jnilib是JNI库的文件扩展名。 Since I'm using JNA, I wouldn't expect JNA to be using any JNI library other than its own one, "jnidispatch". 由于我使用的是JNA,所以我不希望JNA使用其自身的“ jnidispatch”之外的任何JNI库。
  • JNA is looking on the classpath for this file, but there is no way in hell it will be there because it's just some random library I'm trying to import. JNA正在查找此文件的类路径,但是在地狱中它是不可能的,因为它只是我尝试导入的某个随机库。 Shouldn't it be looking on DYLD_FRAMEWORK_PATH ? 它不应该在DYLD_FRAMEWORK_PATHDYLD_FRAMEWORK_PATH吗?
  • Other native libraries which are initialised in exactly the same way work fine. 以完全相同的方式初始化的其他本机库也可以正常工作。 For instance, CoreFoundation can be resolved. 例如,可以解决CoreFoundation。 Its code for loading the library is the same aside from the name of the library being different. 除了库名不同外,它用于加载库的代码是相同的。

I tried looking at the frameworks themselves and can only see minor differences: 我尝试查看框架本身,只能看到微小的差异:

  • FREngine.framework is in /Library , CoreFoundation.framework is in /System/Library FREngine.framework/LibraryCoreFoundation.framework/System/Library
  • FREngine.framework/Versions contains a directory with a longer and more complex name than CoreFoundation.framework , which only has one version called A . FREngine.framework/Versions包含一个名称比CoreFoundation.framework更长且更复杂的目录,该目录只有一个名为A版本。
  • FREngine.framework/Versions/[ver] contains Headers and Libraries FREngine.framework/Versions/[ver]包含HeadersLibraries

The version of JNA in use is 3.5.2. 使用的JNA版本是3.5.2。 We can't upgrade to 4.x because there is some other bug which causes an exception as soon as we try to load our native library. 我们无法升级到4.x,因为一旦尝试加载本机库,还有其他一些错误会导致异常。

The reason why FREngine library does not work in this case in a wrong Engine load method. 在这种情况下FREngine库在错误的Engine加载方法下不起作用的原因。 FREngine is expected to be loaded via com.abbyy.FREngine only. FREngine只能通过com.abbyy.FREngine加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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