macos macosx-version-min 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2923502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what does macosx-version-min imply?
提问by Quincy
When I pass compiler flag -mmacosx-version-min=10.5
, what does it mean? I think it implies the result binary is x86, not ppc, but is it 32 bits or 64 bits? I'm compiling on snow leopard, so default output binary is 64 bits. I'm not passing -universal
, it's not 32bit-64bit universal binary, I think.
当我通过 compiler flag 时-mmacosx-version-min=10.5
,它是什么意思?我认为这意味着结果二进制是 x86,而不是 ppc,但它是 32 位还是 64 位?我在雪豹上编译,所以默认输出二进制是 64 位。我没有通过-universal
,我认为它不是 32 位-64 位通用二进制文件。
采纳答案by Laurent Etiemble
This option will be used by the various availability macros placed into the headers. This means that you can require a minimum version of OS, even if you have a more recent SDK (i.e. target 10.5 with a 10.6 SDK). Using a 10.6 API while targetting 10.5 will trigger a warning and the API will be linked with a weak_import attribute.
此选项将由放置在标题中的各种可用性宏使用。这意味着您可能需要最低版本的操作系统,即使您有更新的 SDK(即目标 10.5 和 10.6 SDK)。在面向 10.5 的同时使用 10.6 API 将触发警告,并且该 API 将与weak_import 属性链接。
Most Apple's API headers contains availability macros for each class, methods, functions or enumerations in order to declare for each of them:
大多数 Apple 的 API 标头包含每个类、方法、函数或枚举的可用性宏,以便为每个类声明:
- The minimum OS supported
- The deprecation
- The unavailability
- ...
- 支持的最低操作系统
- 弃用
- 不可用
- ...
The macros look like:
宏看起来像:
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED
- ...
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED
- ...
As for the architecture, it only depends on the available architectures in the binaries of the SDK. For example with a 10.5 SDK, you can target four architectures (Intel/32bits, PowerPC/32bits, Intel/64bits, PowerPC 64bits), while with a 10.6 SDK, you can only target three architecture (Intel/32bits, PowerPC/32bits, Intel/64bits).
至于架构,它只取决于SDK二进制文件中可用的架构。例如,对于 10.5 SDK,您可以针对四种架构(Intel/32bits、PowerPC/32bits、Intel/64bits、PowerPC 64bits),而对于 10.6 SDK,您只能针对三种架构(Intel/32bits、PowerPC/32bits、英特尔/64 位)。
As you are using Snow Leopard, you can either target i386 (Intel/32bits), ppc (PowerPC/32bits) or x86_64 (Intel/64bits) very simply by passing an architecture option like this:
当您使用 Snow Leopard 时,您可以非常简单地通过传递这样的架构选项来定位 i386(Intel/32bits)、ppc(PowerPC/32bits)或 x86_64(Intel/64bits):
gcc -arch i386
or like this (for configure-based projects):
或者像这样(对于基于配置的项目):
CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure
回答by Kristian Spangsege
-mmacosx-version-min=...
also influences the default choice of C++ STL implementation (GNU or LLVM), and in this regard, it is equally important for the compiler and the linker.
-mmacosx-version-min=...
也影响 C++ STL 实现(GNU 或 LLVM)的默认选择,在这方面,它对编译器和链接器同样重要。
回答by qu1j0t3
From my testing, it's also important that this option be passed to the link step (like -arch); so it does more than affect macros/preprocessing (as might be inferred from other answers).
根据我的测试,将此选项传递给链接步骤(如 -arch)也很重要;所以它不仅仅影响宏/预处理(从其他答案中可以推断出)。
When passed to compile step but not passed to the link step, I found that shared libraries built with 10.6 would not load under 10.5.
当传递到编译步骤但没有传递到链接步骤时,我发现用10.6构建的共享库在10.5下无法加载。
回答by Nikolai Ruhe
It triggers compiler warnings for methods that appeared after Mac OS X 10.5. Is has nothing to do with architecture.
它会触发 Mac OS X 10.5 之后出现的方法的编译器警告。与建筑无关。