3

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.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • Welcome Nilanka - please take a look at http://stackoverflow.com/help/how-to-ask. Your title is not clear what you need, which is the error message. – micstr Jan 21 '16 at 07:13
  • Is the dll listed in the 'build.properties' to be included in the build? – greg-449 Jan 21 '16 at 07:57
  • Yes, in the fragment. I even tried using buddy policy. No success. – Nilanka Wijewardana Jan 21 '16 at 08:05
  • The exact error is java.lang.UnsatisfiedLinkError: Unable to load library 'xxx.dll': Can't obtain InputStream for win32-x86/xxx.dll But I cound see the dll is found according to the logs - (NativeLibrary.java:259) loadLibrary(..) : Found library resource at bundleresource://441.fwk9634012:5/xxx.dll – Nilanka Wijewardana Jan 21 '16 at 08:25
  • The full message suggests it is looking in a 'win32-x86' directory. Maybe try putting the dll in the 'lib' subdirectory and specifying 'lib/xxx.dll' in Bundle-NativeCode. – greg-449 Jan 21 '16 at 09:45
  • It's possible that the library is found but then subsequently fails to load due to other DLL dependencies, at which point JNA will continue to try other locations. Include the full output of JNA's DLL search process. – technomage Jan 21 '16 at 16:17

1 Answers1

2

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.