30

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.

Devid Farinelli
  • 7,514
  • 9
  • 42
  • 73
Quincy
  • 1,923
  • 5
  • 27
  • 37

4 Answers4

24

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
Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
  • I had to #include to get these macros in plain C. But available.h is also included in stdlib.h – Hans-Christoph Steiner Sep 28 '11 at 15:07
  • 1
    See also @Kristian's answer below. In addition I have found that a minimum version equal to and above 10.8 will generate slightly different symbols (the linking of the `_start` symbol has changed, likely in line with the new default C++ library). – Ephemera May 17 '14 at 06:07
12

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

Kristian Spangsege
  • 2,903
  • 1
  • 20
  • 43
11

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.

qu1j0t3
  • 720
  • 8
  • 15
5

It triggers compiler warnings for methods that appeared after Mac OS X 10.5. Is has nothing to do with architecture.

Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200