install_name_tool -change和-id之间的区别 [英] install_name_tool difference between -change and -id
问题描述
我在这个概念上苦苦挣扎了一段时间,我无法真正理解-change
和-id
之间的区别.手册页指出
I have been struggling with this concept for a while and I cannot really understand what the difference is between -change
and -id
.The man page states
-id name
Changes the shared library identification name of a dynamic shared library to name. If the Mach-O binary is not a dynamic
shared library and the -id option is specified it is ignored.
-change old new
Changes the dependent shared library install name old to new in the specified Mach-O binary. More than one of these options
can be specified. If the Mach-O binary does not contain the old install name in a specified -change option the option is
ignored.
到目前为止,我已经尝试过-change
.假设我具有以下结构
So far I have experimented with -change
. Suppose I have the following structure
Test.App
|_Contents
|_MacOS
| |_test -----> item A
|_Library
|_test_library.dylib --->item B
|_another_library.dylib --->item C
现在假设我在itemB上运行了以下内容
Now suppose I ran the following on itemB
$ otool -L test_library.dylib
test_library.dylib
/some/path/another_library.dylib -->item D
以上结果表明test_library.dylib
现在依赖于another_library.dylib
,如果我需要更改another_library.dylib
的位置,我会这样做
The above result indicates that test_library.dylib
depends on another_library.dylib
now if I needed to change the location of another_library.dylib
I would do this
install_name_tool -change /some/path/another_library.dylib some/new/path/another_library.dylib test_library.dylib
这将更改项目D的位置.我的问题是install-name_tool -id
会做什么,何时使用它?
this would change the location of item D. My question is what does install-name_tool -id
do and when do I use that ?
推荐答案
我的理解是:
-id
:这将设置在与动态库链接时将使用的安装名称".它将在目标动态库文件上运行.
-id
: This sets the "install name" that will be used when linking against the dynamic library. It would be run on the target dynamic library file.
-change
:这将在链接后更改安装名称",并将在与目标动态库链接的可执行或动态库上运行.
-change
: This changes the "install name" after linking and would be run on the executable or dynamic library that links against the target dynamic library.
这篇关于install_name_tool -change和-id之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!