Mac Installation FAQ

From Free Pascal wiki

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

Logo OSX.png

This article applies to macOS only.

See also: Multiplatform Programming Guide

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

 xcode-select --install

from the terminal. See also Installing Lazarus on MacOS X 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 X.

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: In newer versions of Xcode GDB is no longer globally available. See GDB on OS X Mavericks or newer and Xcode 5 or newer for possible solutions.

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

Unit XY not found

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.

Other questions

I didn't find my issue here.

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