问题
I often need to target Mac OS X versions that are older than the one I'm currently running. As I prefer to work with a bash shell and Makefiles, I do not use Xcode. Apple explicitly supports targeting older OS X versions, but I've always been confused by the redundancy of the two configuration steps that are usually taken to target older platforms:
gcc is started using
--macosx-version-min
:gcc --mmacosx-version-min=10.6 ....
The
MACOSX_DEPLOYMENT_TARGET
environment variable is set to the desired platform, e.g.export MACOSX_DEPLOYMENT_TARGET=10.6
When trying to figure out the actual difference between the two by searching, you'll come up with different answers. Some people say that they do exactly the same, so it's only necessary to use one of the two. However, there are also voices which say that it's necessary to do both: start gcc with --macosx-version-min
and set the environment variable.
Are these two things exactly the same? Is it only necessary to use one of the two but not both? Is there some official documentation available somewhere? Apple mentions MACOSX_DEPLOYMENT_TARGET but doesn't mention --macosx-version-min
at all, even though it seems to be much more common.
回答1:
The man pages of gcc on Mac OS X say that they're synonymous:
-mmacosx-version-min=version The earliest version of MacOS X that this executable will run on is version. Typical values of version include 10.1, 10.2, and 10.3.9. This value can also be set with the MACOSX_DEPLOYMENT_TARGET environment variable. If both the command-line option is specified and the environment variable is set, the command-line option will take precedence.
来源:https://stackoverflow.com/questions/25352389/what-is-the-difference-between-macosx-deployment-target-and-mmacosx-version-min