macos 使用 install_name_tool 出了什么问题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2985315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:59:14  来源:igfitidea点击:

Using install_name_tool what's going wrong?

macosinstall-name-tool

提问by Thijs Koerselman

I'm trying to change the install path of a dylib after it has been built. I use otool -Lto check what the current path is. And then I do:

我正在尝试在构建 dylib 后更改它的安装路径。我otool -L用来检查当前路径是什么。然后我做:

$ install_name_tool -change /my/current/path/libmine.dylib \
    /my/new/path/libmine.dylib libmine.dylib

I don't get an error, but nothing changes. If I check the path again the old one is still there. Also the new path is a lot shorter then the old one, so no problem there, and I think the lib is even compiled with extra flag for more filepath space.

我没有收到错误,但没有任何变化。如果我再次检查路径,旧路径仍然存在。此外,新路径比旧路径短很多,所以没问题,我认为 lib 甚至使用额外标志编译以获得更多文件路径空间。

Any ideas?

有任何想法吗?

回答by JeremyP

The man page for install_name_tool says that -change is for dependencies. You're trying to change the name of the library itself.

install_name_tool 的手册页说 -change 用于依赖项。您正在尝试更改库本身的名称。

Having just experimented, I found I couldn't change the name of a dylib that appears inside the dylib itself but I could change the names of other dependencies.

刚刚试验后,我发现我无法更改出现在 dylib 内部的 dylib 的名称,但我可以更改其他依赖项的名称。

Having experimented more: install_name_tool -id newname filewill do the trick.

进行了更多实验:install_name_tool -id newname file会成功。