如何查看动态库文件(.dylib)的函数定义?
How to view definition of functions of a dynamic library file (.dylib)?
所以我有一个名为"libxlearn_api.dylib"的动态库文件。我可以通过
从 python 代码中加载这个库
lib = ctypes.cdll.LoadLibrary(/path/to/lib)
我也可以通过dir(lib)看到上面的库中定义了哪些函数。
但是,这只是给出了其中的函数名称列表。
我需要查看这些函数的 description/definition(它们是如何 written/implemented,即实际代码。)
我该怎么做?
I need to view the description/definition of these functions(how they are written/implemented, i.e the actual code.)
一般不可以,因为动态库可能是proprietary (this is the case for many GUI related libraries on MacOSX, read about Aqua).
如果库是 free software,或者如果通过某种(合法的)方式您获得了它的源代码(也许在签署了一些 NDA 并支付了一些钱之后),您可以研究它的源代码。然后您最好从源代码构建该库(以确保二进制库和源代码匹配),否则您需要相信二进制库的提供者它与您获得的源代码完全对应。
顺便说一句,xlearn is free software. Perhaps it is the same as your binary dynamic library (but you need to check). I recommend to be able to build it from its source code (in a terminal, using commands). See its installation guide,部分:从源代码安装。
所以我有一个名为"libxlearn_api.dylib"的动态库文件。我可以通过
从 python 代码中加载这个库lib = ctypes.cdll.LoadLibrary(/path/to/lib)
我也可以通过dir(lib)看到上面的库中定义了哪些函数。 但是,这只是给出了其中的函数名称列表。
我需要查看这些函数的 description/definition(它们是如何 written/implemented,即实际代码。)
我该怎么做?
I need to view the description/definition of these functions(how they are written/implemented, i.e the actual code.)
一般不可以,因为动态库可能是proprietary (this is the case for many GUI related libraries on MacOSX, read about Aqua).
如果库是 free software,或者如果通过某种(合法的)方式您获得了它的源代码(也许在签署了一些 NDA 并支付了一些钱之后),您可以研究它的源代码。然后您最好从源代码构建该库(以确保二进制库和源代码匹配),否则您需要相信二进制库的提供者它与您获得的源代码完全对应。
顺便说一句,xlearn is free software. Perhaps it is the same as your binary dynamic library (but you need to check). I recommend to be able to build it from its source code (in a terminal, using commands). See its installation guide,部分:从源代码安装。