Sign in Join
Wiki copytemporary

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 it stood on 2022-03-15 after a change by Trev, out of the wiki's dump of 2024-05-26. 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 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 1 person, 2020–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
TrevLegacy content moved from macOS Programming Tips
TrevFPC 2.6.1 and below: Fixed context (minor)
TrevFix heading levels (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.