1

我正在尝试将可执行文件放在一起发送到另一台计算机。otool -L "exec_name" 返回:

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

试图将其更改为我的可执行目录:

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

它发出警告:

/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)

但没有任何变化, otool -L 仍然显示:

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

我也试过

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

这给出了一个错误:

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)

无法理解为什么它不会改变路径......

4

1 回答 1

1

两个问题:

  1. @executable_path,不是@executive_path

  2. 您需要在库和链接到它的二进制文件中更改安装名称:

    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]
    

有关安装名称如何工作的更深入解释,请参阅我的这个答案

于 2021-06-21T08:48:02.657 回答