17

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

jofel
  • 3,297
  • 17
  • 31
seanxiaoxiao
  • 1,282
  • 2
  • 11
  • 23
  • 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 Answers5

18

objdump is your friend ;)

$ objdump -f lib/lib.a
oHo
  • 51,447
  • 27
  • 165
  • 200
yves Baumes
  • 8,836
  • 7
  • 45
  • 74
15

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!

Tim Čas
  • 10,501
  • 3
  • 26
  • 32
1

Use file or objdump. file always works but objdump will give you more detailed information about libraries and archives and executables.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
0

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
spnkr
  • 952
  • 9
  • 18
0

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`
Zulan
  • 21,896
  • 6
  • 49
  • 109