[Insight-developers] Installed ITK with shared libraries

Brad King brad.king at kitware.com
Fri Feb 24 11:36:41 EST 2006


Zachary Pincus wrote:
> Hi folks,
> 
> Does anyone know if there are any plans for how ITK will support the  
> use of shared libraries from ITK installations?
> 
> You may have seen the discussion of this on the itk-user or cmake  
> lists, so here is just a brief summary:
> 
> ITK, if built with shared libraries and installed, is not usable on  OS 
> X.  I strongly suspect this is true on most other unix platforms,  and 
> possibly windows too.
> 
> This is because the rpath information for where the dynamic loader is  
> to find the shared libraries is set to the build directory. So if you  
> link against an installed copy of an ITK library, at runtime the  loader 
> will look for the library in the *build directory*. This  directory may 
> not exist any more (or for e.g. an RPM, it may have  never existed on 
> that machine).
> 
> In many cases (certainly on OS X), setting PATH or [DY] LD_LIBRARY_PATH 
> is insufficient because those values will not be  consulted when the 
> library has an absolute rpath.
> 
> This problem can be solved in several ways. One is to create two  
> different versions of each shared library: one with an rpath pointing  
> to the build location, one pointing to the install location. Only the  
> latter is installed. Brad King informs me for some Lunux  distributions, 
> using rpaths at all is of frowned upon.
> 
> The other option is to not have rpaths at all. Then the ITK libraries  
> would need to be installed into a standard location where the loader  
> knows to look, or users would have to set [DY]LD_LIBRARY_PATH (unix)  or 
> PATH (win) to include the installation directory.
> 
> Are there any thoughts as to how this issue ought to be handled in ITK?

Better RPATH support for installed targets built with CMake is provided 
in the CVS version of CMake, and install_name support on OSX will soon 
be committed.  We do not want to require such a new CMake though, so for 
now one should just set CMAKE_SKIP_RPATH when building before doing 
"make install".  Then the installed binaries will have no 
rpath/install_name in them at all and one may set [DY]LD_LIBRARY_PATH to 
use them.

To make this harder to forget we could do in ITK what I did last year in 
VTK which is to provide a VTK_USE_RPATH option.  If this option is ON 
then one can run from the build tree but the install target installs 
nothing and prints a message explaining why.  If the option is OFF then 
one may install but must set LD_LIBRARY_PATH to run either from the 
build tree or from the install tree.

Avoiding the requirement of setting LD_LIBRARY_PATH for the install tree 
can be accomplished by using CMake's shared library version support to 
allow the ITK libs to be installed in PREFIX/lib instead of 
PREFIX/lib/InsightToolkit.  Then the ld.so.conf on the machine would 
help the libraries be found.

-Brad


More information about the Insight-developers mailing list