On a unix/linux system how can I learn more about a mylib.a archive?

霸气de小男生 提交于 2019-12-23 12:38:33

问题


In this particular case I'm trying to discover if a mylib.a file is 32 or 64 bit compatible. I'm familiar with ldd for shared objects (mylib.so) but how do I inspect a regular .a archive?


回答1:


"nm" and "ar" will give you some information about the library archive.




回答2:


$ objdump -G /usr/lib/libz.a
In archive /usr/lib/libz.a:

adler32.o:     file format elf32-i386

...

$ objdump -G /usr/lib64/libz.a
In archive /usr/lib64/libz.a:

adler32.o:     file format elf64-x86-64

...

$ objdump -G /ppc-image/usr/lib/libz.a
In archive /ppc-image/usr/lib/libz.a:

adler32.o:     file format elf32-powerpc

...

Requires a multilib-capable binutils, but it's pretty straightforward, is it not?




回答3:


Standard "nm" and "ar" utilities will give you information about the archive.

To learn about the 32/64 bit ability of the archive use "ar" to extract the .o files inside the mylib.a, then run "file" on the .o files to discover their type including the 32/64 bit usage.




回答4:


In the general case, I just use the 'file' utility.



来源:https://stackoverflow.com/questions/184502/on-a-unix-linux-system-how-can-i-learn-more-about-a-mylib-a-archive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!