macosx-version-min 意味着什么?

发布于 2024-09-03 13:23:16 字数 187 浏览 4 评论 0原文

当我传递编译器标志 -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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

篱下浅笙歌 2024-09-10 13:23:16

此选项将由放置在标头中的各种可用性宏使用。这意味着您可能需要最低版本的操作系统,即使您有更新的 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
  • < code>AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED
  • ...

至于架构,它仅取决于 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 位):

gcc -arch i386

或像这样(对于基于配置的项目) ):

CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure

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 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
  • ...

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:

gcc -arch i386

or like this (for configure-based projects):

CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure
相守太难 2024-09-10 13:23:16

-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.

少年亿悲伤 2024-09-10 13:23:16

根据我的测试,将此选项传递到链接步骤也很重要(如 -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.

温柔嚣张 2024-09-10 13:23:16

它会针对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文