admin管理员组文章数量:1416631
On Linux, the linker option --as-needed
is used to avoid keeping a reference to an unused library.
With this option, if -lxyz
is used in the link command but no symbol from libxyz.so
is used in the application, the executable will not load libxyz.so
. Conversely, with the linker option --no-as-needed
, the library will be loaded even if none of its symbols is referenced in the application. The default depends on the distro (see my previous question here).
What would be the equivalent option on macOS?
On macOS, the options --as-needed
and --no-as-needed
do not exist. The default behaviour is equivalent to --no-as-needed
, the libraries which were mentioned in the link command line are all loaded, even without symbol reference from the application. The command otool -L
on the executable always lists all libraries.
I cannot find any option to avoid loading unused libraries, no equivalent to --as-needed
.
On Linux, the linker option --as-needed
is used to avoid keeping a reference to an unused library.
With this option, if -lxyz
is used in the link command but no symbol from libxyz.so
is used in the application, the executable will not load libxyz.so
. Conversely, with the linker option --no-as-needed
, the library will be loaded even if none of its symbols is referenced in the application. The default depends on the distro (see my previous question here).
What would be the equivalent option on macOS?
On macOS, the options --as-needed
and --no-as-needed
do not exist. The default behaviour is equivalent to --no-as-needed
, the libraries which were mentioned in the link command line are all loaded, even without symbol reference from the application. The command otool -L
on the executable always lists all libraries.
I cannot find any option to avoid loading unused libraries, no equivalent to --as-needed
.
1 Answer
Reset to default 1Answering my own question after a few days of research:
- Linker option:
-dead_strip_dylibs
- Or from the clang command:
-Wl,-dead_strip_dylibs
本文标签: What is the equivalent of asneeded in macOS linkerStack Overflow
版权声明:本文标题:What is the equivalent of --as--needed in macOS linker? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745256383a2650126.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论