[Insight-users] Shared libs discovery problem on Mac osX 10.6.3

Michael Jackson mike.jackson at bluequartz.net
Mon Apr 12 10:25:04 EDT 2010


What you are running into is most likely the absence of a complete  
path to the ITK library within the actual library itself. This is  
referred to as the "install_name" of the library. One way to find out  
the install_name of a library is to use the "otool" command line  
utility.

otool -L /path/to/ITK/Library.

The output will tell you what path is encoded into the library. When  
you link the executable the linker uses this information and embeds  
the path to each depended library into the executable itself. This way  
the executable knows exactly where to find the library. If there is NO  
path encoded in the libraries then YOU need to tell your application  
where to look by using the DYLD_LIBRARY_PATH environment variable.  
This of course works on the command line but NOT with an application  
launched from the Finder**.

    What you need to do is to use the "install_name_tool" program from  
the command line to "fix up" the libraries needed by your application.  
Apple's developer web site has good information on this technique.  
There are some "special" paths that can be used like  
"@executable_path/../lib/" so that you can embed the ITK libraries  
into the Application Bundle in order to make the Application  
relocatable.

Again,
   Using Static libraries will alleviate ALL of these issues.


http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html

http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html

http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html


** It _can_ work but takes more hacking around than it is worth.
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio


On Apr 12, 2010, at 10:10 AM, Antonin Perrot-Audet wrote:

> Hello,
> we are having some trouble making ITK work with shared libraries on  
> Mac osX 1.-0.6.3 I have had this conversations a few month ago, and  
> the answer was to use static libraries.
> The problem comes from the discovery of libraries, which doesn't  
> work correctly.
> I have a correct installation of ITK on my system : build with  
> shared libraries, and installed with "make install"
> When I start the executable, it can't find ITK's shared lib.
>
> I have to add :
> DYLD_LIBRARY_PATH=/usr/local/lib/InsightToolkit/:/usr/local/lib/ 
> vtk-5.7/:$DYLD_$
> export DYLD_LIBRARY_PATH
> to my .profile file for the discovery to work. I can then start the  
> executable from the command line, but the discovery still doesn't  
> work if I start my executable from the finder (not from the command  
> line).
>
> Did anyone has had this problem before ?
> Is there a fix to the ITK installation ?
>
> Thanks,
>
> Antonin
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list