I want to change the rpath of an executable using install_name_tool
, but I can't figure out what the rpath is right now. install_name_tool
requires both the old and the new rpath's to be given on the commandline. What command can I use to print the rpath of an executable under macOS?
First of all, understand that an executable doesn't contain a single rpath
entry, but an array of one or more entries.
Second, you can use otool
to list an image's rpath
entries. Using otool -l
, you'll get output like the following, at the very end of which are the rpath
entries:
Load command 34
cmd LC_LOAD_DYLIB
cmdsize 88
name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24)
time stamp 2 Wed Dec 31 19:00:02 1969
current version 1038.32.0
compatibility version 45.0.0
Load command 35
cmd LC_RPATH
cmdsize 40
path @loader_path/../Frameworks (offset 12)
Look for the LC_RPATH
commands and note the path under the path
entry.