I had a static library file. How can I see whether it is compiled in i386 or in arm platform. Thanks.
-
See my answer then - unbeknownst to many (though you, as a programmer, probably do know) Mac OS X is a fullblown Unix system :) – Tim Čas Feb 13 '12 at 13:05
5 Answers
objdump
is your friend ;)
$ objdump -f lib/lib.a

- 51,447
- 27
- 165
- 200

- 8,836
- 7
- 45
- 74
-
1Thanks :-D just simply than copying file, then archiving it, and finally using `file`. – oHo Feb 13 '12 at 13:35
-
In Unix (and similar - say, Linux or Minix) systems, you can use the "file" utility:
%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)
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 file
package is about 1/3 down the page).
EDIT: For static libraries (.a
files), you first need to extract them and check a .o
file:
%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!
I'm sure there is a way to directly check into these files, but this works just as well!

- 10,501
- 3
- 26
- 32
-
1file command does not give that much information for a static library (.a files). – yves Baumes Feb 13 '12 at 13:09
Use file
or objdump
. file
always works but objdump
will give you more detailed information about libraries and archives and executables.

- 321,842
- 108
- 597
- 820
For libraries linked to iOS apps, here's how to see the architectures of a .a file:
file /path/to/library.a
Example output for a lib built for armv7, armv7s (iPhone 5), arm64, x86_64, and i386:
/path/to/library.a: Mach-O universal binary with 5 architectures: [i386:Mach-O object i386] [x86_64:Mach-O 64-bit object x86_64] [arm_v7:Mach-O object arm_v7] [arm_v7s:Mach-O object arm_v7s] [arm64]
/path/to/library.a (for architecture i386): Mach-O object i386
/path/to/library.a (for architecture x86_64): Mach-O 64-bit object x86_64
/path/to/library.a (for architecture armv7): Mach-O object arm_v7
/path/to/library.a (for architecture armv7s): Mach-O object arm_v7s
/path/to/library.a (for architecture arm64): Mach-O 64-bit object arm64

- 952
- 9
- 18
file
gives you general information about the platform on linux.
e.g.
file /usr/lib/libfoo.a
or for a executable binary
file `which foo`

- 21,896
- 6
- 49
- 109