If I list the dynamic libraries that dcamprof is currently linked against I get this:
otool -L dcamprof
dcamprof:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/local/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
When you launch dcamprof, the loader will look for libraries at those locations, if it finds them it will use them, otherwise it searches for the library on the library search path.
install_name_tool lets you edit the library paths in the dcamprof executable.
The syntax is:
install_name_tool -change <<current lib path>> <<new lib path>> dcamprof
Which means “change the library reference in dcamprof that currently points to <<current path>>
so that it points to <<new path>>
instead”.
The current path must be one of the ones that otool -L lists (otherwise the change is ignored), the new path points to wherever the library should be. You can set it to a relative path, but that isn’t very useful in practice because the path is interpreted as relative to the current working directory when dcamprof is run. There is an option that is more useful - if you set the path to something that starts with @executable_path/
then that path is relative to the location of the dcamprof executable (wherever it may be).
There are also some limits on the length of the path you can set it to, which will depend on the options that were used to link dcamprof in the first place.
So:
install_name_tool -change /usr/local/lib/libomp.dylib @executable_path/libomp.dylib dcamprof
will make dcamprof look for libomp.dylib in the same directory as dcamprof itself.
Running otool again after the above install_name_tool command will show the new library paths:
dcamprof:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
@executable_path/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
Does that make it any clearer?