Search code examples
javaeclipsercpjna

Unable to load library 'xxx.dll': Native library (win32-x86/xxx.dll) not found in resource path (JNA + DLL + eclipse rcp)


I'm using JNA in an eclipse RCP project.

I'm following fragment style.

fragment:`  
`Bundle-SymbolicName: a.b.c.d.win32.win32.x86`  
`Bundle-ClassPath: lib/jna-4.1.0.jar, . `  
`Eclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))`  
`Bundle-NativeCode: xxx.dll;processor=x86; osname=win32,*`  
`Fragment-Host: a.b.c.d

xxx.dll is directly inside a.b.c.d.win32.win32.x86 fragment project.

host:
Bundle-SymbolicName: a.b.c.d

error I get: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'xxx.dll': Native library (win32-x86/xxx.dll) not found in resource path

Need some help.


Solution

  • I'm using jna-4.2.1.
    I downloaded the source and debug.
    What I found was JNA introduces a prefix based on platform.

    String libname = name.startsWith("/") ? name : NativeLibrary.mapSharedLibraryName(name); String resourcePath = name.startsWith("/") ? name : Platform.RESOURCE_PREFIX+ "/" + libname;

    So I included my xxx.dll in a win32-x86 folder.
    But still Native.loadLibrary(xxx.dll,...) should refer the dll by its original name.

    Thanks for the support.