How to see the compilation platform of a static library file

Solution 1:

objdump is your friend ;)

$ objdump -f lib/lib.a

Solution 2:

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!

Solution 3:

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