Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

FPC 2.6.1 macOS Targets

FPC 2.6.1 and below

To make sure that an application will run under previous macOS releases, use the -macosx_version_min linker parameter and link against the appropriate SDK (e.g. -XR/Developer/SDKs/MacOSX10.5.sdk/ or -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/). For example, to compile an application that should work on Leopard 10.5 and higher:

Add to /etc/fpc.cfg OR to Project / Compiler options / Other / Custom options:

pascal
-k-macosx_version_min -k10.5
    -XR/Developer/SDKs/MacOSX10.5.sdk/

The 10.4 SDK is the only one with a special name (10.4u instead of 10.4). Other SDK names simply contain the major macOS version number: MacOSX10.5.sdk, MacOSX10.6.sdk, ...

Note: The path /Developer depends on where you installed the Apple developer tools, and may be different if you chose a different location. Do not assume it will always be /Developer.

The 10.7 is by default:

pascal
-k-macosx_version_min -k10.7
    -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/

For targeting Tiger 10.4 the following settings are required:

pascal
-k-macosx_version_min -k10.4
    -XR/Developer/SDKs/MacOSX10.4u.sdk/

Adding the custom options only when compiling for macOS

To add the above custom options only when compiling for macOS add to Project / Compiler options / IDE macros / Conditionals:

pascal
if TargetOS = 'darwin' then begin
      UsageCustomOptions += ' -k-macosx_version_min -k10.5';
      UsageCustomOptions += ' -XR/Developer/SDKs/MacOSX10.5.sdk/';
    end;

From the Free Pascal wiki, page "FPC 2.6.1 macOS Targets", as the Internet Archive kept it on 2025-03-15, last changed on 2022-03-16. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .