Fsdgh Asdgfsdag
Fsdgh Asdgfsdag

Reputation: 25

Compile with gcc on Macos 10.14.5 that will support earlier versions of Mac

I have a c ++ code that I wrote that uses almost nothing, which is not the language itself (except using osascript).

After compiling it on my operating system version (10.14.5) with the following flags: D_DEBUG, Os, Wall, Wextra

I found that it was not running on older operating systems (in 10.13 for example - it raises an error that it can only run on 10.14 or later)

What are the right flags to use to tell GCC, that I want to support as many MacOs versions as possible?

Upvotes: 1

Views: 1186

Answers (1)

Richard Barber
Richard Barber

Reputation: 6461

You will need a versioning flag: -mmacosx-version-min=10.9

And let the compiler know where the SDK is: -isysroot= =/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk

The older SDKs are available in older xcode bundles, or via https://github.com/phracker/MacOSX-SDKs/releases. You need to decompress the SDK and place the folder inside the xcode bundle, as shown in the sysroot flag above.

Apple sayeth: You must target your compile for the oldest version of OS X on which you want to run the executable. In addition, you should install and use the cross-development SDK for that version of OS X. For more information, see SDK Compatibility Guide

Upvotes: 4

Related Questions