[OpendTect_Developers] Adding external library to current opendtect installation

Bert Bril bert at opendtect.org
Fri Mar 25 12:49:23 CET 2011


Hi all,


Khaerul Adzany wrote:


> I have successfully adding an external library for my plugin (Alglib,
> http://alglib.net).
> So, I configured opendtect $ODWork (copying the .so, .a and header files
> on their appropriate folders, i think), modifying module list on
> make.od.ModDeps and modfying the plugin's makefile.

So far, so good.


> But there is a problem when I want to run my plugin on a default
> opendtect installation, the plugin was not loaded.

The thing here is to really understand what's happening. If you would
have used the archive (.a file) via EXTRALIBSFORSHLIB, then the extra
lib content would have been put into the plugin's shared library. Then,
when OpendTect loads the plugin, everything is there and the plugin can run.

If you just refer to an external library (as you do), you need to make
sure that it is available, on runtime, for the dynamic linker. You have
to ask yourself: how will the dynamic linker find that library? All it
knows is that there must be a shared lib with a certain name that has to
be loaded.

Thus, let's see what you've done:


>    2. Copy (or link) *.a and * so into $(ODWork)/lib/lux32/G

The .a file is not interesting at all as it contains nothing executable.
The .so file does, but this is not one of the searched directories (see
below).


>    3. Copy *.h files of our external library into $(ODWork)/include/Alglib
>    4. Copy *.cpp/*.cc files of our external library into $(ODWork)/src/Alglib

Sources won't do anything either. I'd leave them be, they're good where
they were.


>    5. Edit make.od.ModDeps file in $(ODWork)/Pmake, adding
> LAlglib := -lAlglib3 and IAlglib := Alglib

That was good, you give the gcc linker the chance to look into the
Alglib3 shared lib.


>    6. Edit our plugin makefile, add Alglib to our MODDEPS variable

That is all for compiling, it won't help the dynamic loader.


>    1. Copy (or link) *.so file into $(ODWork)/bin/lux32/G/so

This comes close. The linker is already looking in certain directories
to find necessary shared libs, but unfortunately not this one.


The resolution is to use a directory where the linker does look. That
would probably be $(ODWork)/bin/lux32/so (i.e. loose the 'G'). Good
tools may be 'ldd' and 'echo $LD_LIBRARY_PATH'.


Another thing you can do (on Linux) is put the original library
directory location in your LD_LIBRARY_PATH.



/Bert

-- 
-- Bert Bril / OpendTect developer at dGB
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org





More information about the Developers mailing list