macosdynamic-linkingdylibotoolinstall-name-tool

Fix paths in dylib files using install_name_tool


I'm trying to compile my C++ project after updating OS to El Capitan. However, I faced a few snags along the way:

dyld: Library not loaded: pathB/libIceUtil.34.dylib
Referenced from: pathA/libSlice.34.dylib
Reason: image not found

The problem is that pathB doesn't exist. When I run otool -L pathA/libIceUtil.34.dylib, I get

pathA/libIceUtil.34.dylib:
pathB/libIceUtil.34.dylib (compatibility version 0.0.0, current version 0.0.0)

install_name_tool -change pathB/libIceUtil.34.dylib pathA/libIceUtil.34.dylib pathA/libIceUtil.34.dylib didn't solve the problem. An article mentions using libtool. Any idea how I can fix this issue?


Solution

  • The first argument to install_name_tool -change is not correct (it doesn't match what otool -L printed). Use:

    install_name_tool -change \
        /Volumes/Data/builder/Proj/gcc4/thirdparty/Ice-3.4.2-x86_64/lib/libIceUtil.34.dylib \
        /Users/xeroqu/lib/Proj/gcc4/thirdparty/Ice-3.4.2-x86_64/lib/libIceUtil.34.dylib \
        /Users/xeroqu/lib/Proj/gcc4/thirdparty/Ice-3.4.2-x86_64/lib/libIceUtil.34.dylib