Free Pascal For Mac

This article applies to macOS only.

See also: Multiplatform Programming Guide

English (en)

This page lists solutions to the most frequent problems that may arise during (and after) installation of Lazarus and Free Pascal on macOS. Please read Installing Lazarus on macOS first and pay special attention to the sections that apply to your versions of macOS, Xcode, Lazarus and Free Pascal.

Free Pascal is a mature, versatile, open source Pascal compiler. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS. To install them manually, open '/Applications/Utilities/Terminal', execute 'xcode-select -install' and choose 'Install'. Afterwards, FPC will function correctly. Xcode 4.3 - 5.x compatibility (Mac OS X 10.7 Lion/OS X 10.8 Mountain Lion) FPC 3.2.0 is qualified for use with Mac OS X 10.4 till macOS 10.15 Xcode 4.3 and later however no longer install the command line tools by default, which.

Pascal free download. Free Pascal Compiler A 32/64/16-bit Pascal compiler for Win32/64/CE, Linux, Mac OS X/iOS, Android, FreeBSD, OS/2, Game Bo. Free Pascal is a professional 32 and 64-bit Pascal compiler. It is multiplatform and open source that integrates with Xcode and is available for various processor architectures, among them: Intel x86, Amd64/x8664, PowerPC, and PowerPC64. 7/10 (8 votes) - Download Free Pascal Mac Free. Downloading Free Pascal free will allow you to develop applications in Pascal language. Compile, fix errors and launch applications thanks to Free Pascal. Pascal is a procedural programming language, designed in 1968 and published in 1970 by Niklaus Wirth and named in honour of the French mathematician and philosopher Blaise Pascal. Pascal runs on a variety of platforms, such as Windows, Mac OS, and various versions of UNIX/Linux.

Lazarus doesn't run project

After moving to macOS or after upgrading to a new version of macOS Lazarus is unable to compile and run a project.

Solution: Most likely, this behaviour results from missing command line tools. In newer versions of Xcode they are no longer installed by default. You can install them by running

from the terminal. See also Installing Lazarus on macOS for more details.

Compilation aborts with weird messages

I have correctly installed Lazarus and FPC, but compiling a simple demo program stops with the Free Pascal exit code 256 and the message 'Lazarus Panic /bin/sh: clang: command not found'.

Solution: This behaviour may arise from a too old Xcode version installed. Generally, you should use the newest Xcode version that is available for your operating system. Lazarus 1.6 requires, e.g., Xcode 3.2.6, or newer. With Xcode 4.3 or newer, you should also install the Xcode command line tools as described above or in the article Installing Lazarus on macOS.

ld: symbol(s) not found for architecture i386

I am trying to compile a blank project on Catalina immediately after installing FPC and Lazarus but I get this error 'ld: symbol(s) not found for architecture i386'.

Solution: Go to Lazarus > Tools > Options, if your compiler may be set to ppc386 (32 bit), then change it to ppcx64 (64 bit) or fpc (a wrapper that should choose the correct compiler). There is no 32 bit support in Catalina. In the trunk version of Lazarus, the Lazarus > Tools > Options menu has been moved to the Lazarus > Preferences menu How to download monopoly full version free for pc.

Debugger not found

I have installed the latest version of Lazarus on a new Mac. My program is built fine, but when I try to run it I get a message that the debugger /usr/bin/gdb doesn't exist or isn't runnable.

Solution: Since version 5, Xcode does not include the GDB debugger but the LLDB debugger. For recent versions of macOS, go to the Tools > Options | Debugger menu and choose 'LLDB debugger (with fpDebug) (Beta)' and set the executable to /usr/bin/lldb.

Solution (legacy): Xcode v5 no longer includes the GDB debugger. See GDB on OS X Mavericks or newer and Xcode 5 or newer for possible solutions unless you are running a recent version of macOS (in which case, see above).

Form not shown after moving to Mac

My application works well on Windows and Linux, but after changing to Mac my forms are invisible. I tried to re-scan the FPC source directory, and I clicked 'Create Bundle', but this didn't solve the problem. Unlike my app, a very simple demo application works well.

Solution: This may result from a wrong position setting of your form(s). Your Windows machine may have a multi-monitor setup, so that the forms are outside the visible area of a single-monitor environment, i.e. if your Mac has only one monitor. You should check and correct the top and left properties of your forms in the object inspector. (Of course, this also applies in the other direction, i.e. if you have a multi-monitor Mac and a single-monitor Windows or Linux machine).

Form not responding to mouse clicks

After starting the program the form is visible, but not responding to interaction via the user interface.

Solution: Programs for macOS-based systems are more complex than programs for Windows or Linux. They require the existence of an application bundle, a special opaque directory structure, which determines the modalities of interaction with the operating system and the GUI. You may create an application bundle in the project settings or alternatively via shell commands. Make sure that the option Use Application Bundle for running and debugging (for Darwin) is checked.

fpcsrc not present

After installing and first running Lazarus, the welcome window complains that the directory '/usr/local/share/fpcsrc' is not found.

Solution: You have to install fpcsrc. This is a Lazarus-specific installer package that comes with your distribution of Lazarus. If you have downloaded Lazarus from SourceForge you find fpcsrc in the same server directory as the Lazarus package.

Multiple error messages after upgrading Lazarus and/or FPC

After upgrading Lazarus and/or Free Pascal to a new major version, trying to compile my code results in multiple error messages.

Solution: This behaviour may have multiple reasons. After every major upgrade you should rescan the FPC source directory. If this doesn't help it may be useful to delete the file fpcdefines.xml (it is within the ~/.lazarus folder). Additionally, you should check your code for incompatibilities that may result from changes in the compiler (although this is quite rare with code that is not too unusual). See Category:FPC User Changes by release for intentional changes to the compiler that may break existing code.

Mac

Unit XY not found

Free pascal macros

I have freshly installed a new version of Lazarus on my machine. Trying to compile an application results in the error message 'Error: unit not found: XY'. (XY is a place holder for any unit name.)

Solution: Try to re-scan your FPC source directory via the Tools.. menu of the IDE.

Fatal: Cannot find [..] used by [..], incompatible ppu=[filename], package [package name]

When the compiler gives the message 'Cannot find A used by B', Lazarus checks what pas/pp/ppu files are in the search path, and if there is a ppu file it inserts 'incompatible ppu=filename, package'.

Explanation: FPC cannot use this ppu for one of these reasons:

  • it was compiled with another FPC version;
  • it was compiled with (depends on) some other ppu files that are not in the search path;
  • you misconfigured some search path(s).

Solutions: (1) Check that you have the current Xcode (optional - see here) and Xcode command line tools package (mandatory) installed; (2) Lazarus > Menu > Tools > Configure Build Lazarus - Find and check 'Clean all' and then Build. If that doesn't work, I'd be tempted to delete both FPC + Lazarus and start again. See Uninstalling Lazarus and Free Pascal.

Error: User defined: only cpu i386 is supported

When compiling Lazarus on macOS I receive this error: carbonbars.pp(16,2) Error: User defined: only cpu i386 is supported

Solution:

Download Free Pascal Ide

Error: ld: framework not found Cocoa

When compiling Lazarus on macOS I receive this error: Error: ld: framework not found Cocoa

Solution: You forgot to install the Xcode command line tools or they've since been deleted. See Installing Xcode Command Line Tools to resolve. You may also need to re-install FPC _after_ installing the Xcode command line tools so that it can find the macOS frameworks.

Download

Error ppc1 not found

When compiling the Free Pascal Compiler on macOS I receive this error:

Solution: GNU Make does not handle directory names with spaces in them. Rename 'fpc trunk' to 'fpc_trunk' or similar and it should work without this error.

Free Pascal Ide For Mac

Error: library (X11 or Truetype) not found

If you are compiling X11 applications (typically using fpGui) FPC needs to know where to find the libX11.dylib and libfreetype.dylib libraries. If FPC cannot find these libraries, you will receive a library not found error during linking.

Solution: Depending on your version of macOS or XQuartz these may be found in /usr/X11/lib or /opt/X11/lib with a symlink from /usr. The best solution to this is probably to edit /etc/fpc.cfg and add the line '-Fu/usr/X11/lib'

Application does not accept keyboard input

After compiling my application, I cannot enter anything in the edit boxes and the application will not accept any keyboard input.

Solution: You forgot to create an application bundle. Lazarus > Project > Project Options > Application - Create Application Bundle.

Warning arm64 function not 4-byte aligned

When compiling on an Apple Silicon M1 processor, I get a 'warning arm64 function not 4-byte aligned' for every function.

Solution: That's probably a consequence of using -Os. That setting unconditionally sets procalign (jump align) to 1. That's definitely wrong for AArch64 and a bunch of other architectures. There is no 'minimum required alignment' for these settings defined yet anywhere in the compiler, so that will need to be added. In the meantime, do not use -Os to optimize size.

Resource compiler 'fpcres' not found

When compiling an application after installing or compiling a new Lazarus version, it fails with the error 'Error (9021) Resource compiler 'fpcres' not found, switching to external mode'

Solution: Create a file called .fpc.cfg (note the leading dot in the filename) in your home directory and add the lines:

If the file already exists it should contain the first of the lines above, so just add the second line.

Other questions

I didn't find my issue here.

Solution: You might find a possible solution at the Lazarus and Free Pascal Forum. Otherwise, you might ask your question there.

See also

Retrieved from 'https://wiki.freepascal.org/index.php?title=Mac_Installation_FAQ&oldid=146117'

English (en)

This article applies to Mac OS Classic only.

See also: Multiplatform Programming Guide

MacOS is the target for Mac OS Classic, i.e. the predecessor to macOS. macOS itself was previously marketed as Mac OS X and OS X. For macOS, see Target Darwin.

  • 2Some tips
  • 5Cross compiling from Mac OS X to Mac OS

Compiling in MPW

Free Pascal can now be used in the MPW development environment.

Free Pascal for MPW call assembler and linker via ToolServer. This means that you need ToolServer installed. This will normally not be an issue, since ToolServer is included in the MPW distribution.

In rare instances, you might get the error message 'Can't call the assembler, switching to external assembler.' I do not know the origin of this, but it will help to restart. On Mac OS X you might need to restart even OSX. It might also indicate that you need to increase the memory setting for ToolServer.

Another workaround for such problems is to let the compiler write out an MPW script (option -s). This will assemble and link when executed in MPW. This method can also be used if the compiler is to be called from a third program, to overcome the deadlock situation mentioned below under Dos.Exec.

For crosscompiling e.g. from macOS to Mac OS Classic, see below.

Some tips

Choosing apptype

For casual users, copying Pascal text only programs from a book, {$APPTYPE CONSOLE} is appropriate.

If you want an MPW tool, use {$APPTYPE TOOL}.

For maximum portability, the following:

.. ensures it will be an MPW tool on Mac OS, and a console application in Delphi where {$APPTYPE TOOL} is not recognized.

Resources

Since 24-01-2004 mac style resources can be included with {$R <resfile>}. If the resource file ends with .r it is considered a Rez type resource file (in text form). For all other files (including .rsrc), binary resources are assumed. Several resource files can be included.

Error messages

Errors, warnings, hints and other messages written by the compiler are in MPW format - that is you can execute them and the error location will be displayed.

Dos.Exec

The procedure Dos.Exec is used to execute other programs. In MacOS this is supported, and the program(s?) which can be executed is MPW tools. An AppleEvent is sent to ToolServer which in turn executes the tool. A limitation is that ToolServer is not reentrant, so if a program which is called via Dos.Exec, in turn call Dos.Exec, it will be deadlocked.

Assembler symbols

Internal symbols in the generated assembler files will have a lowercase 's' as part separator instead of '$'. The reason is that PPCAsm does not support $.

QuickDraw globals

There is a variable qd defined in System.pp for use as the QuickDraw global.

Download free pascal for mac

For {$APPTYE TOOL} and {$APPTYPE CONSOLE} it is initialized, but for {$APPTYPE GUI} you have to initialize it yourself.

Debugging

See MPW debugging

Global variables

Currently all global variables are indirect, i.e. the entry in the TOC is always a pointer to data. (In the future small data items may be stored directly in the TOC)

Thus all references to globals are via a construct like: lwz rX, yyy[TC](r2) ;loads a pointer to a global into rX

Cross compiling from Mac OS X to Mac OS

Although not necessary nowadays when there exists a native compiler for target MacOS, here is some info on how to cross compile. See also Link on target.

Crosscompiling step on macOS

When compiling, add these options:

If make is used, add OPT=-st OS_TARGET=macos

Free Pascal For Mac

Note that one must first build the RTL by issuing make in rtl/macos, with the above options, to be able to build other programs. The RTL must then be assembled and linked (see below) before compiling any program, otherwise the search paths in the link script will not be correct.

You might also want to add option -a, then the link script will not delete unneeded files, in particular the assembler files (*.s). This can be useful if there are problems with the link scripts and you want to rerun it.

Assembling and linking step on Mac OS Classic

In case that host and target machine is different, transfer the produced files (assembler files (*.s) and link script *_ppas) to the host.

In Mac OS Classic, use MPW to assemble and link the output from FreePascal by executing the link script (which is an MPW script), with its directory as current directory. Unfortunately the link script does not(?) obtain the proper mac file type, so this has to be fixed first e.g. with the MPW command SetFile.

Example: To build Hello World (together with the rtl unit system.pp), execute:

Above circa 2004/5.

Working notes: situation as of late 2012

Free Pascal Macos Catalina

The objective here is to build PPC and possibly 68K compilers, first as cross-compilers to run on a PC and then to run natively on Mac OS 9. Part of the incentive for this is to investigate whether a PPC Mac, e.g. my (MarkMLl) G3 beige with 'Old World' ROMs, is a usable testbed for the fixed 68K compiler which Sven has added to trunk at around 2.8.

On e.g. Debian Linux, build and install cross-binutils:

Do the same for m68k-linux-gnu.

Build a cross-compiler to run on a PC but targeting PPC:

Download Free Pascal For Mac

Renaming the compiler prevents it from being deleted by make clean etc., consider extending that OPT setting with -dEXTDEBUG.

Build a native RTL and compiler:

Bringing macos/sysdir.inc up to date shows that the amiga, embedded, watcom and symbian OS targets are similarly falling behind. It's instructive to compare the amiga target (which has not been updated) with the morphos target (which has).

There's also a problem inside the compiler itself where entries of type AT_NONE are being generated but not handled.

To be continued.

Retrieved from 'https://wiki.freepascal.org/index.php?title=Target_MacOS&oldid=129380'

Comments are closed.