iOS:Unix:Mac extract info from a static lib regarding supported architecture(s). How?

笑着哭i 提交于 2019-12-08 03:59:58

问题


I have a static library on my Mac and curious to know if the lib was built for armV7s architecture or not? Is any command/tools available to show the supported architectures in this library?

Thank you, Kamran


回答1:


You may use otool for getting that information.

From otool's manpage

-L Display the names and version numbers of the shared libraries that the object file uses. As well as the shared library ID if the file is a shared library.

Example

> otool -L libRaptureXML_universal.a 

Archive : libRaptureXML_universal.a (architecture armv7)
libRaptureXML_universal.a(RXMLElement.o) (architecture armv7):
Archive : libRaptureXML_universal.a (architecture i386)
libRaptureXML_universal.a(RXMLElement.o) (architecture i386):



回答2:


your-mac:~ yourlogin$ file /Path/to/somebinary

/Path/to/somebinary: Mach-O universal binary with 3 architectures
/Path/to/somebinary (for architecture x86_64):    Mach-O 64-bit executable x86_64
/Path/to/somebinary (for architecture i386):      Mach-O executable i386
/Path/to/somebinary (for architecture ppc7400):   Mach-O executable ppc



回答3:


Not disagreeing with the other answers, but here's one more option: use the lipo command.

The Apple man pages for lipo

You can run lipo -info on executables, or libraries. Some examples:

minime:arc username$ lipo -info libarclite_iphonesimulator.a
input file libarclite_iphonesimulator.a is not a fat file
Non-fat file: libarclite_iphonesimulator.a is architecture: i386

minime:iPhone username$ cd HelloWorld.app/
minime:HelloWorld.app username$ lipo -info HelloWorld
Non-fat file: HelloWorld is architecture: armv7


来源:https://stackoverflow.com/questions/12537617/iosunixmac-extract-info-from-a-static-lib-regarding-supported-architectures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!