macososx-elcapitanrpathotoolinstall-name-tool

Unable to change @rpath on osx


I've got an external lib 'libspecial.dylib' with following dependencies.

otool -L libspecial.dylib                                                                                                                          [11:20:59]
libspecial.dylib:
     @rpath/libspecial.dylib (compatibility version 1.0.0, current version 1.0.1)
     @rpath/libhelper.dylib  (compatibility version 1.0.0, current version 1.0.1)

Because @rpath causes problems I have a script replacing all @rpath with the real path.

install_name_tool -change @rpath/libspecial.dylib /tmp/libspecial.dylib libspecial.dylib
install_name_tool -change @rpath/libhelper.dylib  /tmp/libhelper.dylib  libspecial.dylib

But this only replaces the second dependency (in fact there are more dependencies, all are replaced but not the first one which points to the lib itself):

otool -L libspecial.dylib
libspecial.dylib:
     @rpath/libspecial.dylib (compatibility version 1.0.0, current version 1.0.1)
     /tmp/libhelper.dylib    (compatibility version 1.0.0, current version 1.0.1)

I have no idea why I can't change the first depencdency. Any ideas?

Running on OSX 10.11.1


Solution

  • Ok, I realized that the first "dependency" isn't a dependency as such, it is more the name of the lib. I can also see it when using

    otool -D libspecial.dylib
        @rpath/libspecial.dylib
    

    So the command was just wrong. It can be fixed with

    install_name_tool -id libspecial.dylib libspecial.dylib