[Insight-users] ITK, OS X and install_name

Zachary Pincus zpincus at stanford.edu
Thu Aug 17 14:18:45 EDT 2006


Great; I'll submit the request.

For reference, CMake is doing *something* with the install_name. In  
the build tree, the install_name is the path to the lib's location.  
In the install tree, the install_name has been stripped. And  
fortunately, the libs are compiled with the name padding maxed out so  
that it's easy to add new and different install_names.

This makes it easy to temporarily fix the problem with  
install_name_tool: just rename the libraries and fix the inter- 
library dependencies. (Below is a python script [requires v2.4 for  
the 'subprocess' module; oh well] that demonstrates how to do this in  
batch mode.)

Zach


import glob
import os
import subprocess

files = glob.glob("*.dylib")
cwd = os.getcwd()

change_command = ['install_name_tool']
for file in files:
   if os.path.islink(file): continue
   p = subprocess.Popen(['otool', '-D', file], stdout = subprocess.PIPE)
   old_name = os.path.split([l for l in p.stdout][-1].strip())[1]
   new_name = os.path.join(cwd, old_name)
   change_command.extend(['-change', old_name, new_name])
   subprocess.call(['install_name_tool', '-id', new_name, file ])

for file in files:
   if os.path.islink(file): continue
   subprocess.call(change_command +[file])





On Aug 17, 2006, at 6:03 AM, Brad King wrote:

> Zachary Pincus wrote:
>> Hi folks,
>>
>> I've been out of the loop for a little while on ITK, so apologies if
>> this question has come up before. (I can't find it in the archives  
>> though.)
>>
>> Anyhow, I just cvs-updated and rebuilt ITK on my OS X machine. This
>> time, I took the step of installing ITK into a shared directory so  
>> other
>> users could link to the ITK libraries. However, this doesn't work
>> because the ITK build process is not setting any install_name for the
>> installed ITK libraries. So while the linker can find the  
>> libraries at
>> build time, the loader can't find them at runtime because there is no
>> install_name. The only way to make things work is to always  
>> remember to
>> set the DYLD_LIBRARY_PATH environment variable to point to the place
>> that the ITK libraries live. (Or to put the ITK libs in one of the
>> default load directories like /usr/lib/.)
>>
>> I think that CMake now has the ability to include a proper  
>> install_name
>> for libraries, so that this sort of muppetry can be avoided. (See  
>> e.g.
>> http://mail.kde.org/pipermail/kde-buildsystem/2006-February/ 
>> 001426.html
>> ) Is support for install_name planned for ITK on OS X?
>>
>> If so, can I help with that in any way?
>
> Please submit a feature request to the bug tracker for this and assign
> it to me.  We can discuss the design there to make sure it is  
> documented.
>
> Thanks,
> -Brad
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list