We distribute in Linux a static lib in both 64-bit and 32-bit versions. When troubleshooting a customer, I would like my diagnostic shell script to quickly eliminate the issue by checking the .a archive file to detetmine whether it is 32 or 64 bit. The methods that occur to me are less than elegant:
extract a .o member and ask the "file" command (e.g., ELF 32-bit etc)
start including a dummy member coded to indicate, e.g. 32bit.o/64bit.o and use "ar -t" to check
I have tried "strings xyz.a | grep 32" but this doesn't work well over versions. Not a heartbreaker problem, but if you know of an elegant solution, I would like to know.
If you're interested in the CPU itself, look at /proc/cpuinfo for details about the CPU(s) detected by the Linux kernel. which tells us that it's a 32-bit executable using the Intel 80386 instruction set (possibly with extensions). Note that it isn't quite as simple as 32-bit versus 64-bit architectures.
So, we can say /usr/lib/libc. a is a 64-bit static library. The “elf32-*” indicates all object files in the library use 32-bit addresses.
To install 32-bit libraries on Ubuntu 13.04 (64-bit) or later, open Terminal and type: sudo apt-get install lib32z1 (you will need to enter your password). Then just for good measure, let's make sure your Ubuntu is up to date. Type sudo apt-get update and lastly, restart your computer.
objdump
seems like the best way:
objdump -f libfoo.a | grep ^architecture
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With