macosx-version-min暗示什么? [英] what does macosx-version-min imply?

查看:862
本文介绍了macosx-version-min暗示什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过编译器标记 -mmacosx-version-min = 10.5 时,它是什么意思?我认为这意味着结果二进制是x86,而不是ppc,但它是32位还是64位?我正在编译雪豹,所以默认输出二进制是64位。我没有传递 -universal ,我认为它不是32位-64位的通用二进制文件。

解决方案

这个选项将被放置在头文件中的各种可用性宏使用。这意味着即使您拥有更新的SDK(即具有10.6 SDK的目标10.5),也可以要求最低版本的操作系统。使用10.6 API的同时定位10.5将触发警告,并且API将与weak_import属性链接。



大多数Apple的API标头包含每个类,方法,函数或枚举以声明它们中的每一个:


  • 支持的最低操作系统

  • 弃用

  • 不可用

  • ...


    这些宏看起来像:


    • AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER

    • 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 i386LDFLAGS = -  arch i386./configure 


    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.

    解决方案

    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
    

    这篇关于macosx-version-min暗示什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆