macos 如何打印从动态库导出的符号列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4506121/
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 07:29:06  来源:igfitidea点击:

How to print a list of symbols exported from a dynamic library

macosdylib

提问by Gerald

So I've been trying to get dynamic libraries to work in my XCode project under Mac OS X. So far no joy.

所以我一直在尝试让动态库在我的 Mac OS X 下的 XCode 项目中工作。到目前为止,没有任何乐趣。

I am able to load the dylib file, but when I call dlsym to get the function pointer, it returns 0 and dlerror says symbol not found.

我能够加载 dylib 文件,但是当我调用 dlsym 来获取函数指针时,它返回 0 并且 dlerror 表示找不到符号。

So I am wondering if there is a simple way to list the symbols that are exported from a dylib file. Any ideas would be great.

所以我想知道是否有一种简单的方法可以列出从 dylib 文件中导出的符号。任何想法都会很棒。

回答by linuxbuild

Use otool:

使用otool

otool -TV your.dylib

OR

或者

nm -g your.dylib

回答by Omkar Ramtekkar

Use nm -a your.dylib

利用 nm -a your.dylib

It will print all the symbols including globals

它将打印所有符号,包括全局变量

回答by Sahil Doshi

Use Mach-OView for viewing all the Symbols in dylib

使用 Mach-OView 查看 dylib 中的所有符号

https://sourceforge.net/projects/machoview/

https://sourceforge.net/projects/machoview/