Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
664 views
in Technique[技术] by (71.8m points)

macos - Determine minimum OSX version a binary was compiled for

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...