macosx-version-min 意味着什么?
当我传递编译器标志 -mmacosx-version-min=10.5
时,这意味着什么?我认为这意味着结果二进制文件是 x86,而不是 ppc,但它是 32 位还是 64 位?我在雪豹上编译,所以默认输出二进制是 64 位。我没有传递 -universal
,我认为它不是 32 位-64 位通用二进制文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
此选项将由放置在标头中的各种可用性宏使用。这意味着您可能需要最低版本的操作系统,即使您有更新的 SDK(即目标 10.5 和 10.6 SDK)。在定位 10.5 时使用 10.6 API 将触发警告,并且该 API 将与weak_import 属性链接。
大多数 Apple 的 API 标头包含每个类、方法、函数或枚举的可用性宏,以便为每个类、方法、函数或枚举进行声明:
宏如下所示:
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
至于架构,它仅取决于 SDK 二进制文件中的可用架构。例如,使用 10.5 SDK,您可以针对四种架构(Intel/32 位、PowerPC/32 位、Intel/64 位、PowerPC 64 位),而使用 10.6 SDK,您只能针对三种架构(Intel/32 位、PowerPC/32 位、英特尔/64 位)。
当您使用 Snow Leopard 时,您可以非常简单地通过传递如下所示的体系结构选项来定位 i386(Intel/32 位)、ppc(PowerPC/32 位)或 x86_64(Intel/64 位):
或像这样(对于基于配置的项目) ):
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.
Most Apple's API headers contains availability macros for each class, methods, functions or enumerations in order to declare for each of them:
The macros look like:
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).
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:
or like this (for configure-based projects):
-mmacosx-version-min=...
还会影响 C++ STL 实现(GNU 或 LLVM)的默认选择,在这方面,它对于编译器和链接器同样重要。-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.根据我的测试,将此选项传递到链接步骤也很重要(如 -arch);所以它不仅仅影响宏/预处理(可以从其他答案推断)。
当传递到编译步骤但未传递到链接步骤时,我发现使用 10.6 构建的共享库在 10.5 下无法加载。
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).
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.
它会针对 Mac OS X 10.5 之后出现的方法触发编译器警告。与建筑无关。
It triggers compiler warnings for methods that appeared after Mac OS X 10.5. Is has nothing to do with architecture.