How do I determine the target architecture of static library (.a) on Mac OS X?

后端 未结 5 536
再見小時候
再見小時候 2020-12-04 05:33

I\'m interested in verifying if a given iPhone static library has been built for ARM or Intel.

It\'s more curiosity than anything. Is there some kind of Mac OS X o

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 06:17

    As an alternative, I've found objdump can work well. As an example, in my environment I build library archives with vxWorks and need to link those into other projects. To test whether the archive is the correct architecture, I could do something like the following (bash syntax):

    if [ "$(objdumpsparc -a ${ARCHIVE_FILE} 2>&1 | ggrep -cvP 'elf32-sparc-vxworks')" -ne "0" ]; then
      echo "Cannot build with ${ARCHIVE_FILE}, it contains one or more non-sparc components"
    fi;
    

    This example isn't precisely correct, because some lines DO show up that don't say elf32-sparc-vxworks, but it's easy enough to adapt this.

    One nice benefit of this is that objdump, or a similarly named variant, is installed on most *nix operating systems, whereas tools suggested in other responses aren't.

    edit It just occurred to me the OP was asking on OSX. My apologies.

提交回复
热议问题