确定为二进制文件编译的最低OSX版本 [英] Determine minimum OSX version a binary was compiled for

查看:93
本文介绍了确定为二进制文件编译的最低OSX版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用Clang或GCC的Darwin后端为OSX创建可执行文件时,标志-mmacosx-version-min=version可用于设置可执行文件将运行的最早的OSX版本.

When using Clang's or GCC's Darwin backends to create executables for OSX, the flag -mmacosx-version-min=version can be used to set the earliest version of OSX the executable will run on.

是否有任何方法可以从给定的可执行文件中追溯使用哪个标志来对其进行编译? IE.有没有办法确定给定可执行文件的目标最低OSX版本?

Is there any way to trace back from a given executable which flag was used to compile it? I.e. is there a way to determine which minimum OSX version is targeted by a given executable?

推荐答案

使用otool -l /path/to/binary并检查LC_VERSION_MIN_MACOSX加载命令;具体是版本字段.

Use otool -l /path/to/binary and inspect the LC_VERSION_MIN_MACOSX load command; specifically, the version field.

例如,用10.8 SDK编译且目标部署为(-mmacosx-version-min)10.8的二进制文件应具有如下所示的LC_VERSION_MIN_MACOSX:

For example, a binary compiled with the 10.8 SDK with deployment target (-mmacosx-version-min) 10.8 should have an LC_VERSION_MIN_MACOSX like this:

Load command 9
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.8
      sdk 10.8

而使用10.8 SDK(部署目标为10.7)编译的二进制文件应具有如下所示的LC_VERSION_MIN_MACOSX load命令:

whereas a binary compiled with the 10.8 SDK with deployment target 10.7 should have an LC_VERSION_MIN_MACOSX load command like this:

Load command 9
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.7
      sdk 10.8

这篇关于确定为二进制文件编译的最低OSX版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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