Can't find dependent libraries of native module (DLL) [message #61708] |
Wed, 15 February 2006 15:53  |
Eclipse User |
|
|
|
Setup: Sun JRE 5.0_6, Windows XP, Eclipse 3.1.2
I have a piece of native code that I'm loading from a bundle, but it's
unable to find the dependent libraries that are packaged next to them.
I've tried configuring all of the DLLs using the Bundle-NativeCode
manifest header, as well as just placing them in the "os/win32/x86" folder
within the bundle, but they both fail to load the dependent DLLs.
Here's an example of the plug-in's structure:
Plugin
* ModuleLoader - System.loadLibrary("module_java");
* /os/win32/x86/module_java.dll
* /os/win32/x86/module.dll
The Java code loads the "module_java.dll" fine, but the "module.dll" isn't
found and I get a popup that says "The application has failed to start
because MODULE.dll was not found. Re-installing the application may fix
this problem." Within the VM an error is thrown:
"java.lang.UnsatisfiedLinkError:
C:\dev\ws\default_3_1\pluginA\os\win32\x86\module_java.dll: Can't find
dependent libraries".
If I move the dependent DLLs into the PATH, everything works fine, but
this defeats the purpose of packaging the DLLs into the bundles. Any
thoughts or suggestions on getting these dependent DLLs in the path?
Thanks,
-Nathan
|
|
|
Re: Can't find dependent libraries of native module (DLL) [message #61733 is a reply to message #61708] |
Wed, 15 February 2006 19:53   |
Eclipse User |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
Firstly, using os/ws/arch is a deprecated way of referring to DLLs. For OSGI stuff,they should be in the root (preferably provided by a fragment, so you can partition the OS stuff out into different fragments).
Secondly, the problem is that whilst Eclipse knows the search directory to look for these things, Windows doesn't. In this case (presumably) module_java.dll refers to module.dll so the resolution goes like:
Eclipse: Hey, Windows, can you have a look for module_java? I'm pretty sure I've seen it in os/win32/x86 somewhere.
Windows: No problem. Oh look, here it is (loads dll). Hang on a sec, it turns out that module_java.dll needs module.dll. I'll look for it in the only place I know; the PATH. Nope, not in /windows/system32, nope, not in /windows/dll/ ...
So the problem is that whilst Eclipse tells windows where to load the original DLL from, Windows isn't smart enough to look in exactly the same place for dependent libraries. (Putting '.' on the path doesn't help either, because '.' is the directory from where you launched Eclipse.exe).
However, all is not lost. You can give Windows a helping hand:
Eclipse: Hey, Windows. Can you load 'module.dll' for me? It's in os/win32/x86.
Windows: Sure, no problem.
Eclipse: Hey, Windows. Can you load 'module_java.dll' for me? It's in os/win32/x86.
Windows: Sure. Hang on, it turns out module_java.dll depends on module.dll. Fortunately, I've already loaded it before so I'll just use it.
In a nutshell;
System.loadLibrary("module");
System.loadLibaray("module_java");
and don't forget to get rid of the os/win32/x86 directory structure ...
Alex.
|
|
|
|
|
Re: Can't find dependent libraries of native module (DLL) [message #61944 is a reply to message #61921] |
Thu, 16 February 2006 16:37  |
Eclipse User |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
There's an EclipseBundleLoader and an OSGIBundleLoader class. The former delegates to the latter initially, and the OSGIBundleLoader class looks for DLLs in the root of the plugin. The EclipseBundleLoader uses the older Eclipse-style mecahnism of ${ws}${os}${arch} if it can't be found in the OSGIBundleLoader's lookup.
Although the SWT library is loaded via System.loadLibrary(), I seem to recall that there's a custom classloader kicking around in there that does the resolution. It's a bit vague, but I seem to recall that there's a method like 'resolveLibrary(String name)' that does 'return name + "-" + os + "-3139".
If I ever come across it again, I'll post it here :-)
Alex.
|
|
|
Powered by
FUDForum. Page generated in 0.03175 seconds