Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Bundle-NativeCode and LD_LIBRARY_PATH
Bundle-NativeCode and LD_LIBRARY_PATH [message #91398] Sat, 30 June 2007 17:01 Go to next message
Eclipse UserFriend
Originally posted by: tbone13.gmx.de

Hello out there!

I've got a big problem with native libraries inside a plugin.

There are about 36 *.so inside <plugin-folder>/os/linux. For each of
them i added a line
os/linux/lib*.so.5.1.0; osname=linux; processor=x86; (last w/o ';')
under Bundle-NativeCode-Header.

But it takes no affect at all even if i delete this. the only solution
is to add all dependencies to my LD_LIBRARY_PATH via run-Configuration.

All *.so in /os/linux depened on one another, and also on libjvm.so,
libjawt.so and libmawt.so

I'm searching for a way, not to set LD_LIBRARY_PATH but keep it running,
so i can export my plugin within a RCP-App.

Next thing is how to share the loaded libraries across several
classloaders, but I think I'll start a seperate thread for this.

Have a nice Weekend!

Tobi Schröder
Re: Bundle-NativeCode and LD_LIBRARY_PATH [message #91413 is a reply to message #91398] Sat, 30 June 2007 21:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

It's probably an ordering issue.

If you have System.loadLibrary("a"), and "a" depends on "b", then the OS will try and load "b" automatically. However, it won't find "b" because it's not on LD_LIBRARY_PATH, and so give up (or PATH on Windows).

On the other hand, if you do System.loadLibrary("b"), then it will work. You'll then be able to do System.loadLibrary("a"), and that will also work, because you have previously loaded "b".

The trick is then to find which order to load "a" and "b".

If you have 10 DLLs, one (inefficient) way is to put all the System.loadLibrary() calls in a 'for' loop that runs through loading them all 10 times. If you're a little more intelligent, you'd have a list that maintains a list of unloaded DLLs, and then when a DLL is loaded succesfully, remove it from the list. You can then iterate a total of X times loading each item in the list until the list is empty (in which case they're all loaded) or until you exceed X (in which case you've got a missing dependency, and it won't work).

Hope that helps,

Alex.

PS you could try the 'for' loop to trivially see if this solves your problem, then optimise afterwards.
Re: Bundle-NativeCode and LD_LIBRARY_PATH [message #91663 is a reply to message #91413] Fri, 06 July 2007 17:51 Go to previous message
Eclipse UserFriend
Originally posted by: tbone13.gmx.de

Hello World!

First of all: Thanks Alex.
Unfortunately it won't help. It seems to be more complex. I think the
trouble is, that I use a Library that uses AWT as standard
GUI-Component. I bridge it with SWT_AWT to my Viewer. It works, as far
as I set the LD_LIBRARY_PATH to the folder where all libs are nested and
add also the pathes to libjawt libmawt and libjvm.
So the following works inside a class extending java.awt.canvas

static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkRenderingJava");
try {
System.loadLibrary("vtkHybridJava");
} catch (Throwable e) {
System.out.println("cannot load vtkHybrid, skipping...");
}
try {
System.loadLibrary("vtkVolumeRenderingJava");
} catch (Throwable e) {
System.out.println("cannot load vtkVolumeRendering, skipping...");
}
}

I think I leave this for the moment as is. There more problems bothering me.

Greetings!

Tobi

Alex Blewitt schrieb:
> It's probably an ordering issue.
>
> If you have System.loadLibrary("a"), and "a" depends on "b", then the OS will try and load "b" automatically. However, it won't find "b" because it's not on LD_LIBRARY_PATH, and so give up (or PATH on Windows).
>
> On the other hand, if you do System.loadLibrary("b"), then it will work. You'll then be able to do System.loadLibrary("a"), and that will also work, because you have previously loaded "b".
>
> The trick is then to find which order to load "a" and "b".
>
> If you have 10 DLLs, one (inefficient) way is to put all the System.loadLibrary() calls in a 'for' loop that runs through loading them all 10 times. If you're a little more intelligent, you'd have a list that maintains a list of unloaded DLLs, and then when a DLL is loaded succesfully, remove it from the list. You can then iterate a total of X times loading each item in the list until the list is empty (in which case they're all loaded) or until you exceed X (in which case you've got a missing dependency, and it won't work).
>
> Hope that helps,
>
> Alex.
>
> PS you could try the 'for' loop to trivially see if this solves your problem, then optimise afterwards.
Previous Topic:Equinox and OSGi Webinar
Next Topic:Equinox on a servlet
Goto Forum:
  


Current Time: Sat Sep 21 00:53:40 GMT 2024

Powered by FUDForum. Page generated in 0.04019 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top