macos 如何查看静态库文件的编译平台

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

How to see the compilation platform of a static library file

cmacosunix

提问by seanxiaoxiao

I had a static library file. How can I see whether it is compiled in i386 or in arm platform. Thanks.

我有一个静态库文件。怎么看是i386编译的还是arm平台编译的。谢谢。

回答by Tim ?as

In Unix (and similar - say, Linux or Minix) systems, you can use the "file" utility:

在 Unix(和类似的 - 例如 Linux 或 Minix)系统中,您可以使用“文件”实用程序:

%file /lib/libc.so.7
libc.so.7: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, stripped

(the %indicates a shell prompt and is not part of the command)

%表示 shell 提示,不是命令的一部分)

As for Windows, I don't know if there is a built-in command already present, but if not, you can find the utility on this page: http://gnuwin32.sourceforge.net/packages.html(the filepackage is about 1/3 down the page).

至于Windows,我不知道是否已经存在内置命令,但如果没有,您可以在此页面上找到该实用程序:http: //gnuwin32.sourceforge.net/packages.html(该file包是大约在页面下方的 1/3)。

EDIT: For static libraries (.afiles), you first need to extract them and check a .ofile:

编辑:对于静态库(.a文件),您首先需要提取它们并检查.o文件:

%cp /usr/lib/libchipmunk.a .
%ar -x libchipmunk.a
%file *.o
chipmunk.c.o: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), not stripped
<snip>

WARNING:ar -x ...will pollute the local directory, so be sure to copy the files somewhere else (say /tmp/something) first!

警告:ar -x ...会污染本地目录,所以一定/tmp/something要先将文件复制到其他地方(比如)!

I'm sure there is a way to directly check into these files, but this works just as well!

我确信有一种方法可以直接检入这些文件,但这也同样有效!

回答by yves Baumes

objdumpis your friend ;)

objdump是你的朋友 ;)

$ objdump -f lib/lib.a

回答by Zulan

filegives you general information about the platform on linux.

file为您提供有关 linux 平台的一般信息。

e.g.

例如

file /usr/lib/libfoo.a

or for a executable binary

或者对于可执行二进制文件

file `which foo`

回答by Aaron Digulla

Use fileor objdump. filealways works but objdumpwill give you more detailed information about libraries and archives and executables.

使用fileobjdumpfile始终有效,但objdump会为您提供有关库、档案和可执行文件的更多详细信息。