在LINUX中,确定.a库/归档是32位还是64位? [英] In LINUX determine if a .a library/archive 32-bit or 64-bit?

查看:318
本文介绍了在LINUX中,确定.a库/归档是32位还是64位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Linux中分发了64位和32位版本的静态库.在对客户进行故障排除时,我希望我的诊断Shell脚本通过检查.a存档文件来确定它是32位还是64位来快速消除此问题.我想到的方法并不优雅:

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:

  1. 提取一个.o成员并询问文件"命令(例如,ELF 32位等)

  1. extract a .o member and ask the "file" command (e.g., ELF 32-bit etc)

开始包括一个虚拟成员,该成员被编码以指示例如32bit.o/64bit.o,然后使用"ar -t"进行检查

start including a dummy member coded to indicate, e.g. 32bit.o/64bit.o and use "ar -t" to check

我尝试过"strings xyz.a | grep 32",但这在版本上效果不佳.这不是令人心碎的问题,但是,如果您知道一个优雅的解决方案,我想知道.

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.

推荐答案

objdump似乎是最好的方法:

objdump -f libfoo.a | grep ^architecture

这篇关于在LINUX中,确定.a库/归档是32位还是64位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆