views:

65

answers:

2

Hello.

I'm working on a Firefox plugin that uses external libraries to render 3D graphics on the browser.

The problem is that i want the plugin to use external libraries packed with it without changing the LD_LIBRARY_PATH variable.
The libraries are installed in a position relative to the plugin (a shared library too), while the actual executable (i.e. the browser) can be located somewhere entirely else.

Some things that you must know. I'm testing it on Ubuntu (no problem at Windows version of the plugin) My dependencies are OpenSceneGraph libraries and static compilation will make the plugin really big (not an option if there is another one)

Hope you can help me

Best regards.

A: 

You could maybe use the -L flag during the compilation to specify the relative path where the linker can find your shared objects.

If you have already generated your lib, you can link by directly invoking the ldcommand.

Tips : You can easily check if some symbols are defined in a lib using the unix command nm. This is a useful way to check that the linking is well-done.

(If I were you, I would just change temporaly the LD_LIBRARY_PATH as you said in your post. Why don't you want to do this ?)

Elenaher
It is not about the linker finding the libraries, it's about the loader finding them in a location relative to the library currently being loaded (the plugin). With plugins you can't control how the host process (i.e. the browser) is invoked, thus enviroment variables won't do it. On OS X `@loader_path` does the trick, on Linux i don't know.
Georg Fritzsche
Ok sorry for the bad reading. Maybe the best thing to do is using language specific commands to load the lib at runtime. I will probably delete this answer tomorrow if I don't find a way to solve this properly.
Elenaher
The usual dynamic loading has the major disadvantage of not having the stubs, so you have to resolve the symbols manually :/
Georg Fritzsche
A: 

Use the rpath option when linking and specify the 'special' path $ORIGIN.

Example:

-Wl,-R,'$ORIGIN/../lib'

Here's a site that elaborates on using $ORIGIN: http://www.itee.uq.edu.au/~daniel/using_origin/

lothar