Changing dylib library path with install_name_tool -id, nothing changes

1.9k Views Asked by At

I'm trying to put an executable together to send to another computer. otool -L "exec_name" returns:

/usr/local/opt/glfw/lib/libglfw.3.dylib (compatibility version 3.0.0, current version 3.3.0)

trying to change it to my executable directory:

install_name_tool -id @executable_path/libglfw.3.3.dylib libglfw.3.3.dylib

it gives a warning:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: libglfw.3.3.dylib (for architecture x86_64)

but nothing changes, otool -L still shows:

/usr/local/opt/glfw/lib/libglfw.3.dylib (compatibility version 3.0.0, current version 3.3.0)

I also tried

install_name_tool -id @executable_path/libglfw.3.3.dylib libglfw.3.dylib

This gives an error:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open file: libglfw.3.dylib (No such file or directory)

Cannot understand why it would not change the path...

1

There are 1 best solutions below

6
On BEST ANSWER

Two issues:

  1. It's @executable_path, not @executive_path.

  2. You need to change the install name both in the library and the binary that links against it:

    install_name_tool -id @executable_path/libglfw.3.3.dylib libglfw.3.3.dylib
    install_name_tool -change /usr/local/opt/glfw/lib/libglfw.3.dylib @executable_path/libglfw.3.3.dylib [exec_name]
    

For a deeper explanation of how install names work, see this answer of mine.