Installing Lazarus on macOS/es
│ English (en) │ español (es) │ 한국어 (ko) │ русский (ru) │
This article applies to macOS only.
See also: Multiplatform Programming Guide
Instalar Lazarus en una Mac no es particularmente difícil pero es crítico que se haga en el orden correcto. Omitir pasos terminará con certeza en llanto. Al grano, aquí está lo que necesita hacer:
- Descargue e instale Xcode (opcional depende de sus necesidades - ver abajo para detalles).
- Instale las herramientas globales para comandos en línea para Xcode.
- Descargue e instale el paquete de binarios del Compilador de Free Pascal Compiler (FPC) y el paquete de los fuentes de FPC desde Lazarus IDE file area (Importante hágalo antes de instalar el IDE de Lazarus)
- Descargue e instale el IDE de Lazarus desde el área de archivo de Lazarus IDE
- Configure LLDB - el depurador que suministra (y firma) Apple desde adentro del IDE de Lazarus.
Estos pasos se explican en más detalle abajo.
Instalación
Las instrucciones detalladas asumen una reciente versión de MacOS en su Mac, una versión reciente de Xcode y/o herramientas de comandos en línea para Xcode de Apple y una versión reciente de Lazarus. En la página Legacy Information, verá información anterior que pueda ser relevante si está usando componentes antiguos. Puede asistir reemplazando la información desactualizada, tanto borrándola, o, si puede ayudar a alguien que trabaje con un proyecto legado, moverlo a la página legacy information.
En general, esto es acerca de usar los Widget Set Carbon y ‘’’Cocoa’’’. Mientras que Carbon se vio alguna vez como más estable, con el lanzamiento de Lazarus 2.0.8 el Widget Set Cocoa ha sobrepasado a Carbon y debería considerarse seriamente para cualquier proyecto nuevo. Carbon se limitó intencionalmente a 32 bit por Apple y deberá estar consciente de que Carbon y la habilidad de ejecutar programas de 32 bits ha sido removido completamente de MacOS 10.15 Catalina y posteriores versiones las que sólo soportan ejecutables de 64 bits que usan Cocoa.
Paso 1: Descargar Xcode (opcional)
Xcode es una descarga de 12GB la cual tomará hasta 16GB de espacio en disco. Sólo necesitará descargar e instalar el ambiente de desarrollo completo de Xcode si necesita:
- el SDKs para iOS, iPadOS, watchOS y tvOS; ó
- validar y subir aplicaciones a la Mac App Store; ó
- para notarise apps para distribución fuera de la Mac App Store.
Xcode 11.3.1 para usarse en MacOS 10.14 Mojave debe instalarse descargándolo desde (ADC) Apple Developer Connection, el cual es de registro gratuito. Xcode 12.4.x para uso en MacOS 10.15 Catalina y posteriores versiones pueden instalarse desde Mac App store.
Note que debe primero eliminar cualquier versión anterior de Xcode de la carpeta Aplicaciones o renombre Xcode app (p.e. Xcode.app a Xcode_1014.app). Puede entonces seleccionar la versión de Xcode a usarse con la utilidad de comandos en línea xcode-select. Abrir una terminal Applications > Utilities > Terminal y teclear man xcode-select para el manual de utilidad.
Sistemas Anteriores:
Las herramientas para desarrollador de Xcode pueden instalarse desde los discos de instalación originales de MacOS o una nueva copia descargada del sitio (ADC) Apple Developer Connection, el cual requiere de registrarse sin costo. Descargue el archivo Xcode, terminará en su directorio de Descargas como un archivo zip. Abralo. Se desactivará en su directorio de Descargas. Puede que le guste o no. Otros usuarios verán la ruta pero serán incapaces de usarla. Y ahí viene lo confuso. Así que moví el mío y luego escribí xcode-select a donde se movió (en una terminal) -
mv Downloads/Xcode.app /Developer/.
sudo xcode-select -s /Developer/Xcode.app/Contents/Developer
Paso 2: Las Herramientas de comandos en línea de Xcode
Esto se muestra aquí como un paso aparte porque en serio es un paso aparte. No confunda estas herramientas independientes de comandos en línea con las herramientas internas de comandos en línea de Xcode, las que le dirá el GUI de Xcode que ya había instalado aunque ya se había instalado el paquete completo de Xcode en el paso 1. FPC no puede usar esas herramientas de comandos en línea internas sin los cambios de configuración (ver Xcode para detalles).
Haga lo siguiente, es rápido y fácil para todas las versiones de MacOS incluida Catalina 10.15:
sudo xcode-select --install
sudo xcodebuild -license accept
Para Big Sur 11.x y posteriores, sólo necesita entrar el primero de los dos comandos arriba a menos que ya haya instalado el paquete completo de Xcode. Si sólo instaló las herramientas de comandos en línea, debería omitir hacer el comando xcodebuild.
Si tiene problemas instalando las herramientas de comandos en línea usando este método de comandos en línea (p.e. el instalador se congela mientras que “busca Software”), puede también descargar e instalar el paquete de herramientas de comandos en línea ingresando en el sitio Apple Developer Site luego descargar e instalar la imagen de disco de las Herramientas de comandos en línea para Xcode.
Paso 3: binarios FPC código fuente FPC
Descargue e instale el paquete de binarios oficial de FPC y el paquete fuente de FPC por separado en el sitio Lazarus IDE file area.
Cuando llegue al área de archivos del IDE de Lazarus:
- Escoja la versión correcta para su sistema operativo. La vasta mayoría de usuarios Mac deberían escoger los paquetes de 64 bits en el directorio x86-64. Cada computador Mac desde finales de 2006 ha sido funcional a 64 bits. El hecho de que Apple haya dejado completamente todo el soporte a 32 bits desde la versión de MacOS 10.15 Catalina (liberada en Octubre de 2019) es otra razón para escoger los paquetes de 64 bits.
- Escoja la versión de Lazarus que desee instalar y se le presentará con los dos binarios FPC y paquetes fuentes para descargar.
Estos paquetes de instalación se construyeron por los desarrolladores de FPC/Lazarus y versiones formales. Como estos paquetes de instalación no son aprobados por Apple, necesita mantener oprimida la tecla Control, cliquear el paquete y elegir Abrir y confirmar que desea instalar desde un Desarrollador Desconocido.
Podrá gustarle intentar una simple y rápida prueba de FPC en este estado - Probar la instalación FPC.
Paso 4: Instalar el IDE de Lazarus
Es crítico que un Compilador Free Pascal compatible (FPC) y su código fuente deba ser instalado antes que instale el IDE de Lazarus.
Descargue e instale el IDE de Lazarus del sitio Lazarus IDE file area. Cuando esté en el área de archivos, escoja la versión conforme a su sistema operativo. La vasta mayoría de usuarios Mac deberían escoger los paquetes de 64 bits en el directorio Lazarus MacOS x86_64. Cada computador Mac desde finales de 2006 es capaz de ejecutarse a 64 bits. El hecho de que Apple haya abandonado completamente el soporte a 32 bits desde MacOS 10.15 Catalina (liberada en Octubre de 2019) es otra razón para escoger los paquetes a 64 bits.
Paso 5: Configure el Depurador
En versiones de Lazarus 1.8.4 y anteriores, necesita usar gdb como depurador, lento para instalar y difícil de firmar. Desde Lazarus 2.0.0 puede (y debería) usar lldb, un depurador proporcionado por Apple, el cual no necesita firmarse.
Asumiendo que tenga instalado lo que necesite e inicie Lazarus, todo lo que falta será configurar el depurador. Si no hace esto ahora, Lazarus tratará de usar gdb y fallará.
Tenga en cuenta que para depurar aplicaciones de 64 bits, puede que tenga dificultades con lldb por lo que se recomienda instalar una versión de gdb diferente.
- Lazarus versión 2.0.12 con FPC 3.0.4: Es posible instalar gdb y compilar la versión según su versión de S.O. (p.e. El Capitán usará la versión de gdb 7.12.1).
- Lazarus versión 2.2.0: Primero, clique Lazarus > Preferencias > Debugger - Debugger Backend;
- Lazarus antes de la version 2.2.0: Primero, clique Herramientas > Opciones > Debugger.
En la parte superior derecha de la ventana ahora abrir tiene la etiqueta “Tipo de Debugger y ruta”, debe poner tanto el tipo y la ruta. Seleccione el tipo "LLDB debugger (con fpdebug) (Beta)" y seleccione o escriba la ruta /usr/bin/lldb.
Si no se muestra en la lista de selección "LLDB debugger (with fpdebug) (Beta)”, vea abajo Installing LazDebuggerFpLLdb. Las herramientas de comandos en línea instala lldb en el directorio /usr/bin. Guarde esas opciones y puede ahora intentar compilar su programa (clique el pequeño triángulo verde en la parte superior izquierda).
En seguida verá una pregunta capciosa, vea la imagen abajo. Escoja un “Formato de Depuración" de los siguientes -
Martin_fr, la persona que nos ha dado esta interfaz entre el IDE de Lazarus y lldb, sugiere que use "dwarf3" . Luego, necesitará entrar su contraseña, un detalle de MacOS porque una aplicación parece interferir con otra. En este caso, está bien!
Cuando se ejecuta el depurador de vez en cuando se le preguntará por su contraseña para permitir la depuración. Esto es por su propia seguridad.
Información Extra al usar lldb
Un gran acuerdo de información acerca de usar lldb aparece en el sitio this forum thread. —- Aquí hay algunas gemas, de nuevo, de Martin_fr:
En el inesperado caso de problemas, puede no servir intentar "dwarf con sets" en vez de sólo "dwarf3".
La opción de "debug info" sólo afecta las unidades directamente en su proyecto. Sin embargo, las unidades en los paquetes puede que tengan información sobre depuración también. Esto puede ser:
- set por paquete
- para muchos, pero no todos los paquetes en el menú Herramientas > Configurar “Construir Lazarus"
- Project > Project Options > Additions and Overrides
Si se cambia las opciones para un paquete, puede querer revisar qué paquete espera seguir cuando se depura. Los paquetes que no siga, no necesitan la información de depuración.
Si usa un tipo desde un paquete (como TForm de LCL) basta que su unidad (en la cual declaró la variable / vaya a declarar y usar una variable a incluir en el tipo) tenga información de depuración. Reducir el número de paquetes con información de depuración (incluyendo aquellos que por defecto tengan información sobre depuración), puede acortar el tiempo de arranque de los depuradores.
También puede servir comparar (no se ha probado) el tiempo de arranque de los depuradores para las mismas opciones, sólo cambiando el checkbox "use external debug info".
Esto necesita ponerse sólo en su proyecto. Si se pone en su proyecto afectará a todos los paquetes. (Si se pone en un paquete debería no surtir efecto.)
Instalar LazDebuggerFpLLdb
Si instaló desde la fuente y usó el bigide parámetro a construir, entonces el depurador correcto será instalado, como paquete, y liso a usar. Si, no obstante, se instalara de otra forma, puede, o no puede estar ahí.
Desde la pantalla principal del IDE, clique Paquetes->Instalar/DesinstalarPaquetes. Se muestra dos listas de paquetes, la lista de la izquierda está instalada, la lista de la derecha está disponible a instalarse. Busque LazDebuggerFpLldb (exactamente así, hay varios con nombres similares pero son menos adecuados). Si está al lado derecho, clíquelo, presione “Selección a Instalar" y luego “Guardar y reconstruir IDE". Esto tomará algo de tiempo, el IDE se reiniciará y todo deberá estar bien. Ahora regrese a la página y continúe configurando el depurador.
Cocoa 64 bits vs Carbon 32 bits
Usar el marco de Apple de 64 bits Cocoa es ahora innegable para el futuro del Mac. El marco de 32 bits Carbon de Apple, mientras que no se ha estado desarrollando, funciona como se esperaba, pero se le advierte a probar Cocoa primero porque Apple abandonó todo soporte para aplicaciones a 32 bits en MacOS 10.15 Catalina (Octubre 2019).
Es posible construir una versión de Cocoa para el IDE de Lazarus con la versión 2.0.0 y posteriores. Es también posible construir una versión de Carbon del IDE de Lazarus (a menos que esté ejecutando MacOs 10.15 Catalina o posteriores) y lo use para generar binarios Cocoa de 64 bits.
Para producir aplicaciones Cocoa en el IDE Carbon o Cocoa, necesitará poner el Destino a procesador de 64 bits y seleccionar el widgetset Cocoa:
- Abra su proyecto con Lazarus y desde el menú seleccione Proyecto > Opciones de Proyecto
- En el panel "Config and Target" ponga "Target CPU family" en "x86_64" (Intel) o "aarch64" (Apple M1)
- En el panel "Config and Target", si "Current LCL widgetset" no está puesto en Cocoa, clique "Select another LCL widgetset" el cual le lleve al panel de "Additions and Overrides" donde pueda clicar en "Set LCLWidgetType" y poder seleccionar "Cocoa"
- Asegúrese que en Herramientas > Opciones (Lazarus > Preferencias para v2.2.0 y posteriores) que "Compiler Executable" esté puesto en "/usr/local/bin/fpc" para obtener aplicaciones de 64 bits.
- Ahora compile su proyecto - y por favor comuníquese si tiene problemas con su experiencia.
Matriz de Compatibilidad FPC + Lazarus
No toda combinación de Lazarus y Free Pascal es compatible con cada instalación de MacOS. Por favor refiérase a la siguiente tabla para encontrar la versión correcta para su ambiente de desarrollo:
Lazarus 1.8.x | Lazarus 2.0.y | Lazarus 2.0.8 | Lazarus 2.0.10 | Lazarus 2.0.12 | Lazarus 2.2.y | ||
---|---|---|---|---|---|---|---|
FPC 3.0.4 | FPC 3.2.0 | FPC 3.2.2 | |||||
PPC processors | |||||||
Mac OS X 10.4 (Tiger)‡ | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible |
Mac OS X 10.5 (Leopard)‡ | Not tested | Not tested | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible |
Intel processors | |||||||
Mac OS X 10.4 (Tiger)‡ | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible | Incompatible |
Mac OS X 10.5 (Leopard) | Not tested | Compatible^ | Not tested | Compatible^**† | Not tested | Not tested | Not tested |
Mac OS X 10.6 (Snow Leopard) | Compatible | Compatible^^ | Not tested | Not tested | Not tested | Not tested | Not tested |
Mac OS X 10.7 (Lion) | Compatible | Not tested | Not tested | Not tested | Not tested | Not tested | Not tested |
OS X 10.8 (Mountain Lion) | Compatible^^ | Compatible | Compatible**# | Compatible**# | Compatible**# | Compatible# | Compatible |
OS X 10.9 (Mavericks) | Compatible^^ | Compatible | Compatible**† | Compatible**† | Not tested | Not tested | Not tested |
OS X 10.10 (Yosemite) | Compatible^^ | Compatible | Compatible**† | Compatible**† | Not tested | Not tested | Not tested |
OS X 10.11 (El Capitan) | Compatible^^ | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Comptaible |
macOS 10.12 (Sierra) | Compatible^^ | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Compatible |
macOS 10.13 (High Sierra) | Not tested | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Comptaible |
macOS 10.14 (Mojave) | Not tested | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Compatible |
macOS 10.15 (Catalina) | Not tested | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Compatible |
macOS 11 (Big Sur) | Not tested | Compatible | Compatible***† | Compatible† | Compatible† | Compatible† | Compatible |
macOS 12 (Monterey) | Not tested | Not tested | Not tested | Not tested | Not tested | Not tested | Compatible |
macOS 13 (Ventura) | Not tested | Not tested | Not tested | Not tested | Not tested | Not tested | Compatible |
macOS 14 (Sonoma) | Not tested | Not tested | Not tested | Not tested | Not tested | Not tested | Compatible |
Apple Silicon M series processors | |||||||
macOS 11 (Big Sur) | Not tested | Not tested | Not tested | Compatible†† | Compatible†† | Compatible††† | Compatible* |
macOS 12 (Monterey) | Not tested | Not tested | Not tested | Compatible†† | Compatible†† | Compatible††† | Compatible* |
macOS 13 (Ventura) | Not tested | Not tested | Not tested | Compatible†† | Compatible†† | Compatible††† | Compatible* |
macOS 14 (Sonoma) | Not tested | Not tested | Not tested | Compatible†† | Compatible†† | Compatible††† | Compatible* |
x = 0, 2 or 4; y = 0, 2, 4 or 6
^ Carbon interface compiles - Cocoa does not.
^^ Restrictions apply to debugging with gdb.
* Lazarus 2.2.0 installs universal binaries for FPC 3.2.2, but an Intel Lazarus IDE binary which you can use or recompile the IDE from within itself for a native aarch64 version.
** See Installing Lazarus 2.0.8, 2.0.10 with FPC 3.2.0 for macOS 10.10 and earlier for instructions.
*** See Installing Lazarus 2.0.8 with FPC 3.2.0 for macOS 10.11+ for instructions.
# Cannot run without debugging in the IDE. Can run compiled application outside of the IDE. See Issue #37324. Choose the gdb debugger, change timeout option to false or click through five "timeout" dialogs to run with debugging in the IDE.
† Cannot "run without debugging" in the IDE. Can run compiled application outside of the IDE. See Lazarus IDE - Unable to "run without debugging" for workaround. See Issue #36780.
†† You need to compile a native aarch64 version of FPC 3.3.1 (trunk) and Lazarus 2.0.12 from source to support an Apple Silicon M series processor. Refer to these instructions for FPC and these instructions for the Lazarus IDE.
††† After installing FPC 3.2.2, you need to compile a native aarch64 version of Lazarus from source to support an Apple Silicon M series processor. Refer to these instructions for compiling the Lazarus IDE.
‡ See the legacy version of this compatibility matrix for recommended installs on very old versions of macOS.
Instalar versiones del IDE de Lazarus que no han sido lanzadas
Ajustes para Lazarus 2.2
Hay un número de razones por las que pueda mejor usar una versión no-liberada de Lazarus, específicamente, fixes_2_2. En lo particular:
- La necesidad de trabajar Cocoa a 64 bits, pues MacOS 10.15 Catalina y posteriores no dan soporte a Carbon a 32 bits.
- El widget Cococa ha mejorado notoriamente y la interfaz del depurador lldb ha mejorado rápidamente, incluso desde v2.0.0.
- Si su Mac tiene un Procesador Apple M1, el depurador en fixes_2_2 ahora funciona para aarch64.
- Fixes_2_2 es una opción más estable que la rama de desarrollo, pero todavía obtiene las nuevas características mucho más rápidas que la versión a liberar.
Los binarios Pre-compilados basados en fixes_2_2 no están disponibles desde SourceForge así que lo descargamos y construimos desde los fuentes. Un poco lento inicialmente pero muy confiable y una gran prueba para la instalación de su compilador! Necesitará git el cual se incluye en todas las versiones recientes de las herramientas de comandos en línea de Xcode, las que ya debió instalar previamente (ver Xcode Command Line Tools arriba).
Acerca de svn o git: Las herramientas de comandos en línea de Xcode 11.4 en MacOS 10.15 ya no instalan svn, sólo git. Puede instalar la subversión por medio de fink, ports o brew.
Template:Notas sobre la Construcción de Lazarus en Apple Silicon
Descargar los fuentes de Lazarus Fixes 2.2
Cree un directorio para Lazarus y descargue la versión de fixes actual.
cd
mkdir -p bin/lazarus
cd bin/lazarus
Using git:
git clone -b fixes_2_2 https://gitlab.com/freepascal.org/lazarus/lazarus.git laz_fixes
Using svn:
svn checkout https://github.com/fpc/Lazarus/branches/fixes_2_2 laz_fixes
Depending on your internet connection and server congestion this takes a few seconds or a few minutes.
Updating Lazarus Fixes 2.2 source
To keep your fixes_2_2 installation up to date is as easy as:
Using git:
cd ~/bin/lazarus/laz_fixes
git clean -f -d
git pull
Using svn:
cd ~/bin/lazarus/laz_fixes
svn clean --remove-unversioned
svn update
Building Lazarus Fixes 2.2 source
cd laz_fixes
make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide
//-wait some time...
open startlazarus.app --args "--pcp=~/.laz_fixes"
- Note I pass a parameter to use a config directory that is based on the name of the actual install directory. It makes some scripting easy.
- On older macOS versions supporting 32 bit applications, replace the above make line with "make LCL_PLATFORM=carbon CPU_TARGET=i386 bigide " and set up your project as mentioned in the Carbon and Cocoa section below.
You might like to put a small script in your $HOME/bin directory and even set a path to it (very UNIX!)
#!/bin/bash
LAZDIR="laz_fixes"
cd ~/bin/lazarus/"$LAZDIR"
open ~/bin/lazarus/"$LAZDIR"/lazarus.app --args "--pcp=~/.$LAZDIR"
Lazarus development version
- Lazarus Development Version Notes - Note: work in progress
Precompiled binaries based on the development version (was known as "trunk" in SVN; now known as "main" in GIT) of the Lazarus IDE are not available from SourceForge, so here's how to download the development version source using svn or git and build the Lazarus IDE. You will need svn (before macOS 10.15 - Catalina) or git (after macOS 10.14 - Mojave) which is included in the standalone Xcode command line tools which you should have already installed (see Xcode Command Line Tools above).
- When working with an Apple Silicon M1 processor Mac ensure you use the FPC 3.2.2 or later as it provides a universal binary with both a native aarch64 and Intel compiler. If you must use an earlier FPC than 3.2.2 see Apple Silicon Support for how to do this. When building the Lazarus IDE, change the CPU_TARGET in the instructions below from x86_64 (Intel 64 bit) to aarch64 (ARM 64 bit - Apple Silicon M1).
Downloading Lazarus development version source
cd
mkdir -p bin/lazarus
cd bin/lazarus
Using git:
git clone -b main https://gitlab.com/freepascal.org/lazarus/lazarus.git laz_main
Using svn:
svn checkout --depth files https://github.com/fpc/Lazarus/branches all cd all svn update --set-depth infinity main
The above svn invocation is more complex due to a bug in many versions of Subversion. This workaround was the work of Alfred (aka Don Alfredo in the Forum) who is the wizard behind fpcupdeluxe.
Updating Lazarus development version source
To update your existing Lazarus development version source.
Using git:
cd ~/bin/lazarus/laz_main
git clean -f -d
git pull
Using svn:
cd ~/bin/lazarus/laz_trunk
svn cleanup --remove-unversioned
svn update
Building Lazarus development version source
make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 ide
or, or bigger IDE:
make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide
After one of above commands, wait some time and:
open startlazarus.app --args "--pcp=~/.laz_dev"
What does the bigide make argument do?
The bigide make argument adds a bunch of packages to Lazarus that many find useful and cannot do without. The packages that are added are:
|
|
|
The above list is sourced from the [Lazarus source directory]/IDE/Makefile.fpc and may be subject to change.
Note that if you have not compiled your own Lazarus IDE with the bigide argument, you can install any of these packages yourself using the Lazarus IDE Package > Install/Uninstall Packages... dialog.
Installing non-release versions of FPC
Installing from source
There are two current non-release branches of the Free Pascal Compiler: the development (trunk) branch and the Fixes 3.2 branch which includes additional fixes to the released 3.2.2 version. Developers, and those who like living on the bleeding edge and testing new features and fixes, will choose the development version; more normal users, who wish to use a stable branch with some additional fixes since the latest release version, will choose the Fixes branch. The instructions below cover both these branches.
The source code is kept in a version control system called git:
- macOS 10.5 and higher already contain a command line git client if you have installed the Xcode command line utilities.
- You also need the latest released Free Pascal Compiler version (3.2.2 as of March 2022) installed in order to be able to successfully compile the development (trunk) version.
FPC development version
- FPC New Features in development
- FPC User Changes in development - may break existing code.
Note that since the development version of FPC (was known as "trunk" in SVN; now known as "main" in GIT) is by definition still under development, some of the features may still change before they end up in a release version.
Create a directory where you would like to put the source (eg fpc_main in your home directory). You don't need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:
[]$ git clone -b main https://gitlab.com/freepascal.org/fpc/source.git fpc_main
This will create a directory called fpc_main and download the FPC main source to it.
To subsequently update your local source repository with the latest source changes you can simply do:
[]$ cd
[]$ cd fpc_main
[]$ git clean -f -d
[]$ git pull
To build and install FPC (the highlighted text should be all on one line):
[]$ cd
[]$ cd fpc_main
[]$ make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
[]$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
You will also need to update the links for the compiler in /usr/local/bin which will be pointing to the previous FPC version. For example:
[]$ cd /usr/local/bin
[]$ sudo rm ppc386
[]$ sudo rm ppcx64
[]$ sudo ln -s /usr/local/lib/fpc/3.3.1/ppc386
[]$ sudo ln -s /usr/local/lib/fpc/3.3.1/ppcx64
Note that you will need to build a new ppc386
compiler if you want to continue to compile 32 bit applications by replacing these lines (this is not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple's removal of the 32 bit frameworks):
[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
[]$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
with these two lines:
[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppc386 OS_TARGET=darwin CPU_TARGET=i386 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
[]$ sudo make install FPC=$PWD/compiler/ppc386 OS_TARGET=darwin CPU_TARGET=i386
FPC Fixes 3.2
Create a directory where you would like to put the source (eg fpc_fixes32 in your home directory). You don't need to be root to do this. Any normal user can do this. Open an Applications > Utilities > Terminal and do the following:
[]$ git clone -b fixes_3_2 https://gitlab.com/freepascal.org/fpc/source.git fpc_fixes32
This will create a directory called fpc_fixes32 and download the FPC source to it.
To subsequently update your local copy of the repository source with the latest source changes you can simply do:
[]$ cd fpc_fixes32
[]$ git clean -f -d
[]$ git pull
To build and install FPC (the highlighted text should be all on one line):
[]$ cd
[]$ cd fpc_fixes32
[]$ make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
[]$ sudo make install FPC=$PWD/compiler/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
You will also need to update the links for the compiler in /usr/local/bin which will be pointing to the previous FPC version. For example:
[]$ cd /usr/local/bin
[]$ sudo rm ppc386
[]$ sudo rm ppcx64
[]$ sudo ln -s /usr/local/lib/fpc/fixes-3.2/ppc386
[]$ sudo ln -s /usr/local/lib/fpc/fixes-3.2/ppcx64
Note that you will need to build a new ppc386
compiler if you want to continue to compile 32 bit applications by replacing these lines (this may not be possible after Xcode 11.3.1 and macOS 10.14.6 Mojave because of Apple's removal of the 32 bit frameworks):
[]$ make clean all FPC=/usr/local/lib/fpc/3.2.2/ppc386 OS_TARGET=darwin CPU_TARGET=i386 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
[]$ sudo make install FPC=$PWD/compiler/ppc386 OS_TARGET=darwin CPU_TARGET=i386
Known issues and solutions
Lazarus IDE v2.2.0 - rebuilding issue
Any attempt to rebuild the Lazarus IDE from within itself fails with permission errors because the files and directories are owned by a user with the id of 503 whereas most users will find that their id is 501. The solution is to open an Applications > Utilities> Terminal and:
cd /Applications sudo chown -R your_username Lazarus
The following rebuilding errors do not happen on Intel computers
The next error that occurs is that the resource compiler "fpcres" is not found. The solution is to create a .fpc.cfg (note the initial dot) file in your home directory and add these lines to it:
#include /etc/fpc.cfg -FD/usr/local/bin
so that "fpcres" can be found where it was installed.
The next error complains of an unsupported target architecture -Paarch64, with the advice to invoke the "fpc" compiler driver instead - except that is what we are doing already. The solution is to go to Lazarus > Preferences > Compiler executable which is set to /usr/local/bin/fpc and change that to /usr/local/lib/fpc/3.2.2/ppca64 instead.
The IDE will now be successfully rebuilt but will not restart automatically. Trying to then start Lazarus from either the startlazarus.app icon or the lazarus.app icon in /Applications/Lazarus still results in the original Intel lazarus binary being launched. The correct aarch64 binary can be found in ~/.lazarus/bin/aarch64-darwin/lazarus. So the final solution is to open an Application > Utilities > Terminal and:
mv /Applications/Lazarus/lazarus /Applications/Lazarus/lazarus.old mv ~/.lazarus/bin/aarch64-darwin/lazarus /Applications/Lazarus/
You can then start the IDE with either the startLazarus.app or lazarus.app icons. When you do restart lazarus, it is worth returning to the Lazarus > Preferences > Compiler executable which is set to /usr/local/lib/fpc/3.2.2/ppca64 and changing it back to /usr/local/bin/fpc so that you can compile both aarch64 and Intel binaries to, for example, make a Universal Binary which will run on both Intel and aarch64 machines.
Lazarus IDE - Unable to "run without debugging"
If you are using the Lazarus IDE 2.0.10 and the Run > Run without debugging menu option fails with a dialog similar to:
then you need to patch the Lazarus 2.0.10 source code (Issue #37324 and Issue #36780). Specifically, patch ../ide/main.pp as below (unpatched lines shown first, patched lines shown second):
7243,7245c7243,7245 < if RunAppBundle < and FileExistsUTF8(Process.Executable) < and FileExistsUTF8('/usr/bin/open') then --- > if RunAppBundle then > // and FileExistsUTF8(Process.Executable) > //and FileExistsUTF8('/usr/bin/open') then
and recompile the Lazarus IDE.
Alternatively, you can omit patching the source code and simply recompile Lazarus 2.0.10 with FPC 3.0.4.
A similar patching exercise and recompiling, or simply recompiling with FPC 3.0.4, needs to be done for Lazarus 2.0.8 if it has been compiled with FPC 3.2.0.
Upgrading from Mojave (10.14) to Catalina (10.15)
- Run
sudo xcode-select --install
- To enable Lazarus to locate the crt1.10.5.o file change in /etc/fpc.cfg the -Fl behind "#ifdef cpux86_64" from
-Fl/Applications/Xcode.app/Contents/Developer/Toolchain...
to
-Fl/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/
Building the FPC compiler from Mojave (10.14) onwards
- To find the crt1.10.5.o file when building a later Free Pascal Compiler version from source, you need to specify:
OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
on the make command line because FPC ignores the /etc/fpc.cfg configuration file during builds of itself.
Mac Installation FAQ
- See the Mac Installation FAQ for solutions to other common problems that may arise during (and after) installation of Lazarus and Free Pascal on macOS.
Uninstalling Lazarus and Free Pascal
Refer to Uninstalling Lazarus on macOS for uninstallation options.
Legacy Information
See Legacy Information for details of:
- Installing Lazarus on Mac OS X 10.4 (Tiger), Mac OS X 10.5 (Leopard), OS X 10.8 (Mountain Lion)
- Installing Lazarus 2.0.8, 2.0.10 with FPC 3.2.0 for macOS 10.10 and earlier
- Installing Lazarus 2.0.8 with FPC 3.2.0 for macOS 10.11+
- Installing Lazarus on PowerPC-based Macs
- Old Xcode versions
- Installing the gdb debugger
- Compatibility matrix for Lazarus 1.0.0 through 1.6.4 and FPC 2.6.0 through 3.0.2.
See also
- Xcode.
- Other macOS installation options.
- Installing multiple Lazarus versions.
- Mac Portal for an overview of development for macOS with Lazarus and Free Pascal.
- Mac Installation FAQ for solutions to the most frequent problems that may arise during (and after) installation of Lazarus and Free Pascal on macOS.
External links
- Lazarus daily development version download (Intel x86_64)
- Lazarus + FPC daily development version downloads (M1, ARM64, aarch64)
- GIT Succinctly - Free Ebook (PDF, MOBI, EPUB) from SyncFusion.