How to tell if a library is 32 or 64 bit?

Is there some way to do this, other than having the link fail with a message like “skipping incompatible libxxx.a”?

Apparently there are a lot of config scripts that still aren’t smart enough to put 64-bit compiles in /usr/lib64.


Normally if it’s 64bit you would add --libdir=/usr/lib64 also run
the ./configure --help command to see the others.

Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel
up 3:35, 0 users, load average: 0.11, 0.21, 0.17
GPU GeForce 6600 TE/6200 TE - Driver Version:

Hash: SHA1

You can also look at the file with the ‘file’ command. A 32-bit file
comes back with ‘ELF 32-bit…’ and a 64-bit comes back with ‘ELF
64-bit’, or at least they do on my SLED 10 SP2 x86_64 box… different
versions of the ‘file’ command may behave differently… as may other
platforms I suppose.

Good luck.

Malcolm wrote:

> Hi
> Normally if it’s 64bit you would add --libdir=/usr/lib64 also run
> the ./configure --help command to see the others.
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


That was the only suggestion I found with searching, but it doesn’t work for libraries. Executables or .o files return the 32/64 message, libraries just say “current ar archive”.

Sure, that will work with future stuff, but there are a bunch of libraries already out there, so I was hoping for a quick way to check to see what needs to be fixed.

jamesqf - I’m not sure if you ever got an answer to this, but I hit this thread trying to solve the same issue. Since ‘file’ doesn’t print anything meaningful when running against .a files. try using ‘objdump’ instead:

objdump -a <foo.a>

This dumps the archive headers, which have the elf formats. So for example;

~]> objdump -a /usr/local/lib/libavcodec.a

allcodecs.o:     file format elf64-x86-64
rw-r--r-- 513/501  88336 Dec 18 16:41 2008 allcodecs.o

audioconvert.o:     file format elf64-x86-64
rw-r--r-- 513/501  38408 Dec 18 16:41 2008 audioconvert.o

... continues ...

Anyway fwiw, maybe that will help the next wayward soul looking for an answer. :slight_smile:

Thanks ! ApexSpider](