Sign in Join
Wiki copytemporary

Installing the Free Pascal Compiler

English · 中文(中国)

While the Free Pascal Compiler comes pre-built for several processor architectures and operating systems, there may be occasions where a pre-built compiler won't do, and you need to build it yourself. There are a number of reasons for doing this, including:

And the most obvious reason of all:

This document will try to help you do these things.

Overview

There are a number of ways to install the Free Pascal Compiler and its libraries on your system. The current version and trunk, and sometimes beta and release candidates, are available directly from the FPC website (tar, exe, rpm, dmg, pkg files). In addition, versions of FPC are provided (including rpm and deb files) from the Lazarus download site. Linux users can almost certainly find FPC in their distribution's repositories but may find that it is outdated.

It is possible to build FPC from source, typically each release needs to be built with the previous release. It is possible to install FPC in the application space (often requiring root or administrator access) or in a your own user space. These things depend on your particular operating system.

There is an extensive discussion of how to install and build Free Pascal compilers available here http://www.stack.nl/~marcov/buildfaq.pdf - it may be a little too detailed for some users, but it is very comprehensive.

Linux

Downloading FPC binary packages

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: You have a number of way to install FPC presented here, which one is best for you depends very much on what you are planning to do and if you need a very current version. If you are also planning on installing Lazarus, perhaps a quick look at Installing Lazarus and Installing Lazarus on Linux is a very good idea.

With the recent release of FPC 3.2.2, only a few distributions will have the new FPC compiler in its repositories. You can do one of -

pascal
yum localinstall fpc-3.2.2-1.x86_64.rpm
    // or perhaps
    rpm -Uvh fpc-3.2.2-1.x86_64.rpm
pascal
apt install ./fpc-laz_3.2.2-1_amd64.deb

Note the actual name changes from time to time, use the name you downloaded !

If you already have a FPC installed from your distro package manager, you should use that same package manager to remove them before installing under another model. Some quite strange things can happen if your compile uses a mixture of FPC versions !

Downloading FPC tar balls

Another option is installing from a tar, an easy and possibly even more useful model. These tars are available for a wide range of Unix like systems. You need to download the appropriate binary tar for your OS and CPU and you may also need the source files, common for all OS/CPU. You install FPC this way in your own space, not as root.

Here is a series of commands, not a script, that will install FPC on a 64 bit Linux system. It could be scripted but would would need sanity and error checking. Note that I like to install things like this in my $HOME/bin directory, if you prefer having it in $HOME, it is even easier, I am sure you can see the differences.

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: A tar install does not resolve dependencies , if they are not already present, first install binutils, make, gcc.

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: A tar ball install will, if you manage paths properly, allow you to have several versions of FPC installed.

(if you want something a bit newer, please see https://www.freepascal.org/develop.html )

pascal
cd
    mkdir -p bin/FPC/Tars
    mkdir bin/FPC/SRC
    mkdir bin/FPC/fpc-3.2.2
    cd bin/FPC/Tars
    # download src and compiler tars, change for different CPU (or Mac???) 
    
    wget https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz
    wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.x86_64-linux.tar
    
    tar xf fpc-3.2.2.x86_64-linux.tar
    cd fpc-3.2.2.x86_64-linux
    ./install.sh
    # when asked where to install, enter $HOME/bin/FPC/fpc-3.2.2, accept all defaults after that.
    
    cd ../../SRC
    tar xzf ../Tars/fpc-3.2.2.source.tar.gz
    
    # Set a path to where the compiler is, add line at end of .bashrc, if you don't use bash, adjust !
    # (! e.g. Use ~/.profile instead of ~/.bashrc so that the path is available also in Lazarus IDE.)
    echo "PATH=\"\$HOME/bin/FPC/fpc-3.2.2/bin\":\"\$PATH\"" >> ~/.bashrc
    source ~/.bashrc
    
    # trivial test
    cd 
    fpc -iV

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: The second wget above assumes you are working with an amd64 (AMD or Intel) type machine, other platforms require a different tar ball. For example, for a Raspberry Pi , you would use -

pascal
wget https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.arm-linux.tar

which has the armhf 32bit compiler. Incidentally, the Raspberry Pi may need you to increase swap space to at least a Gig if you plan to later build any large applications with FPC.

Downloading FPC sources from Git or zip

If you plan to build your own compiler from source, this is the approach for you.

The FPC source files are stored in a git repository (https://gitlab.com/freepascal.org/fpc/source). The repository keeps track of all the changes by developers in the source tree and has multiple branches. Once you have the sources, please see Installing from source under BSD/Linux for instructions on how to install them.

Anyone can download (but not upload) the source using either git or, easier if you want a one off snapshot, zip. And possibly even SVN. The default is to get the main (aka trunk) version of the source but you also select any one of the very many branches or tags.

Git - is most appropriate if you are going to add or sorrect something in the source and submit your change to the developers. Its a bigger and slower download but once done, easy to keep up to date. Note that its very unlikely contributions to anything other than main will be accepted. Here is an example initial download of main, assuming you already have git installed -

pascal
git clone <https://gitlab.com/freepascal.org/fpc/source>

Once the git download is finished, cd into the new directory and build as documented below. You can now keep your git repository up to date using the normal git commands. Git is well documented online but (https://wiki.freepascal.org/FPC_git) has some fpc specific help.

Zip - a possibly easier option is to download a "zip ball' archive of the source, from the web interface you can select which branch or tag you are interested in (combo box that defaults to 'main'). There are quite a lot of branches and tags to choose from, so please choose carefully. The web interface will let you download the zip of the selected branch or tag directly or command line people may do one of (with the last part of command line indicating which branch):

pascal
wget <https://gitlab.com/freepascal.org/fpc/source/-/archive/fixes_3_2/source-fixes_3_2.zip>
    wget <https://gitlab.com/freepascal.org/fpc/source/-/archive/release_3_2_2/source-release_3_2_2.zip>

You would unzip the zipball and build the source as described below.

Documentation sources

The documentation sources are in a separate repository called fpcdocs, so the command to get them is:

pascal
cd ~
    git clone  https://gitlab.com/freepascal.org/fpc/documentation.git fpcdocs

If you want to learn more about subversion, read this excellent Subversion book which is also available online in different formats for free.

For more information, see the Free Pascal website.

Compiling the FPC source, using preinstalled FPC

pascal
make clean
    make all
    make install INSTALL_PREFIX=install/to/directory

Decide about install/to/directory (default one is /usr/local) and also add options that you need.

pascal
cd install/to/directory/lib/fpc
    mkdir etc
    fpcmkcfg -d basepath="install/to/directory/lib/fpc/\$fpcversion" -o etc/fpc.cfg

Uninstall (assuming default INSTALL_PREFIX is used):

pascal
sudo rm -rf /usr/local/bin/fp*
    sudo rm -rf /usr/local/bin/pas2fpm
    sudo rm -rf /usr/local/bin/instantfpc
    sudo rm -rf /usr/local/lib/fpc
    sudo rm -rf /usr/local/share/doc/fpc*
    sudo rm -rf /usr/local/lib/*/fpc

Compiling the FPC source, using just downloaded FPC 3.2.2

pascal
$ ./install.sh

It will ask several questions in the Terminal, answer them. You will have installed FPC 3.2.2 to the folder e.g. "/home/user/fpc-3.2.2".

pascal
$ git clone <https://gitlab.com/freepascal.org/fpc/source>
pascal
$ make clean PP=/home/user/fpc-3.2.2/bin/fpc
    $ make all PP=/home/user/fpc-3.2.2/bin/fpc

Here you must specify the "PP=" key and the full path to the "fpc" file installed from tarball. Command "make clean" is required if you compile again.

Final compiled binary will be the file "source/compiler/ppcx64".

FreeBSD

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: If you wish to also install Lazarus, you can omit installing FPC with the steps below as the Lazarus port will install it for you. See Installing Lazarus on FreeBSD.

Installing from the ports collection

The FreeBSD ports collection has FPC v3.2.3 version in /usr/ports/lang/fpc and FPC Development v3.3.1 version in /usr/ports/lang/fpc-devel. Nowadays all units were merged into only one package of FPC/FPC-devel. The FPC/FPC-devel source is now installed by default; it previously needed to be copied and uncompressed from /usr/ports/distfiles/freepascal.

This must be done as root.

pascal
# cd /usr/ports/lang/fpc && make install && make clean

If you want use development (aka trunk) version of fpc with all units included do the following:

pascal
# cd /usr/ports/lang/fpc-devel && make install clean

Also, you can install FPC and units from pkg binaries:

pascal
# pkg install lang/fpc

Installing development FPC and units from pkg binaries:

pascal
# pkg install lang/fpc-devel

Once FPC is installed you can check if it's working by simply running as a normal user:

pascal
$ fpc test

which should produce output similar to this:

pascal
Free Pascal Compiler version 3.2.3 [2024/06/17] for x86_64
     Copyright (c) 1993-2024 by Florian Klaempfl and others
     Target OS: FreeBSD for x86-64
     Compiling test
     Fatal: Cannot open file "test"
     Fatal: Compilation aborted
     Error: /usr/local/bin/ppcx64 returned an error exitcode

Installing from tar

Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit FreeBSD, download from x86_64. For i386 32-bit FreeBSD, download from i386.

To install Free Pascal from a terminal:

pascal
$ fetch ftp://ftp.freepascal.org/pub/fpc/dist/3.2.2/x86_64-freebsd/fpc-3.2.2.x86_64-freebsd11.tar
    $ tar -xf fpc-3.2.2.x86_64-freebsd11.tar
    $ cd fpc-3.2.2.x86_64-freebsd
    $ bash install.sh

Replace the desired Free Pascal version (3.0.4, 3.2.0 or 3.2.2) and architecture (x86_64 or i386) as required.

If you want to install the Free Pascal Compiler globally, for example in /usr/local, run the install.sh script as root. install.sh script uses bash shell syntax. If you get Bad substitution error, make sure you run script with bash.

If you are on FreeBSD 12 or newer, the default linker is the lld. This may cause problems if you have code that uses, for example, the cthreads unit as in the following program:

pascal
uses cthreads;
    begin
        writeln('hello'); 
    end.

The executable generated for this program will cause a segmentation fault when run. To fix this issue, you need to install the GNU linker:

pascal
root# pkg install binutils

and add a symbolic-link from /usr/local/bin/ld.bfd to /bin/ld.bfd.

OpenBSD

Installing from tar

Select the appropriate 32 bit/64 bit tar file based on your system. For x86_64 64-bit OpenBSD, download from x86_64. For i386 32-bit OpenBSD, download from i386.

To install Free Pascal from a terminal:

pascal
$ wget https://sourceforge.net/projects/freepascal/files/OpenBSD/3.2.2/fpc-3.2.2.x86_64-openbsd.tar
    $ tar -xf fpc-3.2.2.x86_64-openbsd.tar
    $ cd fpc-3.2.2.x86_64-openbsd
    $ bash install.sh

Replace the desired Free Pascal version (3.0.4, 3.2.0, or 3.2.2) and architecture (x86_64 or i386) as required.

If you want to install the Free Pascal Compiler globally, for example in /usr/local, run the install.sh script as root. install.sh script uses bash shell syntax. If you get Bad subtitution error, make sure you run script with bash. OpenBSD uses ksh as default shell. You need to install bash manually.

Installing from source on BSD/Linux

Effectively, you need:

1. A file with all FPC sources downloaded from git (https://gitlab.com/freepascal.org/fpc/source) or perhaps (https://sourceforge.net/projects/freepascal/files/Source/3.2.2/fpc-3.2.2.source.tar.gz).

2. A starting (bootstrap) FPC compiler. An FPC release can always be built by the previously released FPC version, and FPC trunk can always be built by the current FPC release. You can download a bootstrap Free Pascal Compiler or use your distribution's package management/software system to install one.

FPC build process:

pascal
# Linux use:   
    export MAKE=`which make` ; echo $MAKE 
    # FreeBSD use (default csh, or tcsh):
    set MAKE=`which gmake` ; echo $MAKE
    # FreeBSD use (bash):
    export MAKE=`which gmake` ; echo $MAKE
    $MAKE all OPT='-gl' FPC=/path/to/startingcompiler-name-ppcx64
    # $MAKE is make on Linux and gmake on BSD 
    # /path/to/ can be omitted when ppc386 (32 bit) or ppcx64 (64 bit) is in the path
pascal
$MAKE install FPC=compiler/ppcx64 PREFIX=$THEPREFIX
    #replace the FPC=compiler/ppcx64 (or ppc386 for 32 bit) with the relevant compiler if not on Intel x86
    #THEPREFIX= usually is /usr/local or just /usr, but eg on NetBSD it is /usr/pkg for ports)
pascal
ln -s $THEPREFIX/lib/fpc/3.2.2/ppcx64 $THEPREFIX/bin/ppcx64
pascal
$MAKE install sourceinstall PREFIX=$THEPREFIX
pascal
ln -sf $THEPREFIX/share/src/3.2.2/fpc /usr/share/fpcsrc
pascal
$THEPREFIX/lib/fpc/3.2.2/samplecfg $THEPREFIX/lib/fpc/3.2.0 $ETCDIR

Notes:

pascal
find . >ll

Windows

Installing an FPC release with the Windows installer

Warning-icon.png

Warning: If you are intending to also install Lazarus using the official Windows installer which installs both FPC + Lazarus, please ignore these instructions and instead refer to Installing Lazarus on Windows to avoid having to resolve any resulting conflicts.

By far the easiest way to get a working installation of the Free Pascal Compiler is to download and run the appropriate self-extracting Windows installer from the official SourceForge repository for FPC 3.2.2 - this release contains the current release versions of the Free Pascal Compiler and the Free Pascal libraries. The Windows installer packages install very easily, and should work 'out-of-the-box'. You will be taken through a typical Windows installation wizard to install the FPC binaries and Free Pascal libraries:

Installing from source

Installing from source with a command line git client is not for novices, since you also need a working bootstrap compiler to be able to compile the Free Pascal Compiler from source. Instructions for obtaining a bootstrap compiler are included below.

Obtaining the source with a command line git client

The easiest way to get the Free Pascal Compiler source is by using a git client. The exact commands may vary between git clients; the commands given below are for the command line git client downloadable from GitForWindows.org.

Source for a release version of FPC

First create a directory in which you'd like to keep the source. Any normal user can do this. Create a directory for FPC (eg C:\Source) by typing the following at a command prompt:

pascal
C:\Users\you> cd \
    C:\> mkdir Source
    C:\> cd Source

Now type issue the following command at a command prompt:

pascal
C:\Source> git clone -b release_3_2_2 https://gitlab.com/freepascal.org/fpc/source.git fpc-3.2.2

Wait while the git repository is downloaded to the fpc-3.2.2 directory in your newly created Source directory. This can take a while... have a look at the helpful Free Pascal Forums while you wait :-) You may also like to read the excellent How to use the Forum Wiki article which explains how to get answers to pesky questions quickly. New Forum users are always welcome.

Source for a non-release version of FPC

There are two current non-release branches of the Free Pascal Compiler: the development (main) 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.

If it does not already exist, create a directory in which you'd like to keep the FPC source (eg C:\Source). Any normal user can do this. Now type the following command at a command prompt:

For the Fixes branch of FPC 3.2

pascal
C:\Source> git clone -b fixes_3_2 https://gitlab.com/freepascal.org/fpc/source.git fpc-fixes-3.2.0

For the Development (main) branch of FPC

pascal
C:\Source> git clone -b main https://gitlab.com/freepascal.org/fpc/source.git fpc-main

Hint: To update your local copy of the repository with subsequent changes, you need only do:

For the Fixes branch of FPC 3.2

pascal
C:\> cd C:\Source\fpc-fixes-3.2
    C:\Source\fpc-fixes-3.2> git clean -f -d
    C:\Source\fpc-fixes-3.2> git pull

For the Development (main) branch of FPC

pascal
C:\> cd C:\Source\fpc-main
    C:\Source\fpc-trunk> git clean -f -d
    C:\Source\fpc-trunk> git pull

Obtaining a bootstrap compiler

To obtain a bootstrap Free Pascal Compiler, download the distribution package fpc-3.2.2.i386-win32.exe and run it - it is a self-extracting installer, so just follow the instructions to install it. The installer should set the PATH environment variable as appropriate.

Then restart windows.

Compiling the FPC source

Before you start

pascal
[![fpc windows make.png](/wiki-images/8/8a/fpc_windows_make.png)](</File:fpc_windows_make.png>)
pascal
C:\Source> set PATH=C:\FPC\3.2.2\bin\i386-win32;%PATH%
pascal
* To change it permanently, open Control Panel > System and choose "Advanced system settings" under "Related settings" towards the bottom of the page. Now choose "Environment Variables..." in the System Properties dialog. Here you will probably need to change the Path that appears under "System variables" so that `C:\FPC\3.2.2\bin\i386-win32` occurs first.

Instructions

pascal
C:\> cd Source\fpc-3.2.2
pascal
C:/Source/fpc-3.2.2> make distclean all
pascal
C:/Source/fpc-3.2.2> make install PREFIX=C:\FPC
pascal
C:/Source/fpc-3.2.2> make all OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:\FPC\3.2.2 PP=C:\FPC\3.2.2\bin\i386-win32\ppc386.exe DATA2INC=C:\FPC\3.2.2\bin\i386-win32\data2inc.exe
    
    C:/Source/fpc-3.2.2> make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:\FPC\3.2.2 PP=C:\FPC\3.2.2\bin\i386-win32\ppc386.exe DATA2INC=C:\FPC\3.2.2\bin\i386\win32\data2inc.exe

The cross-compiler to compile programs for Windows 64 bit may now be found here: C:\FPC\3.2.2\bin\i386-win32\ppcrossx64.

Done!

macOS

Warning-icon.png

Warning: If you are intending to also install Lazarus using the official macOS installation packages which install both FPC + Lazarus, please ignore these instructions and instead refer to Installing Lazarus on macOS to avoid having to resolve any resulting FPC conflicts.

Installing an FPC release from the official macOS packages

Step 1: Download Xcode (optional)

Xcode is a 12GB download which will take up 16GB of disk space. You only need to download and install the full Xcode development environment if you need:

Xcode 11.3.1 for use on macOS 10.14 Mojave must now be installed by downloading it from Apple Developer Connection (ADC), which requires free registration. Xcode 11.4.x for use on macOS 10.15 Catalina can be installed from the Mac App store. Note that you must first move any old Xcode versions from the Applications folder into the trash or rename the Xcode app (eg Xcode.app to Xcode_1014.app). You can select which version of Xcode to use with the command line utility xcode-select.

Older systems:

The developer tools can be installed from the original macOS installation disks or a newer copy downloaded from the Apple Developer Connection (ADC), which requires free registration. Download the Xcode file, it will end up in your Downloads directory as a zip file. Click it. It is unarchived into your Downloads directory. You may be happy with it there but maybe not. Other users will see the path to it but be unable to use it. And it is untidy there. So I moved mine and then told xcode-select where it was moved to (in a terminal) -

pascal
mv Downloads/Xcode.app /Developer/.
    sudo xcode-select -s /Developer/Xcode.app/Contents/Developer

Step 2: Xcode Command Line Tools

This is shown here as a separate step because it really is a separate step in addition to Step 1. Don't confuse this with the internal Xcode command line tools that the Xcode GUI will tell you are already installed. FPC does not use those Xcode internal command line tools, so do the following (it is quick and easy)-

pascal
sudo xcode-select --install
    sudo xcodebuild -license accept

You only need to enter the first of the two commands above unless you have also installed the full Xcode package. If you have only installed the command line tools, you should omit entering the xcodebuild command.

Step 3: Download FPC

Download the Free Pascal Compiler (FPC) and FPC source from the Free Pascal website. When you arrive at the download page, select a mirror and then choose the correct version for your operating system.

These installation packages are built by the FPC developers and track formal releases. As these installation packages are not code signed nor notarized by Apple, you need to either control-click on the installation package and choose "Open" or right-click on the installation package and choose "Open" in the contextual menu and confirm you want to install from an Unknown Developer.

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 :

https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png Note: When building a native aarch64 Free Pascal Compiler (ppca64) for an Apple Silicon M1 processor Mac, change the CPU_TARGET in the instructions below from x86_64 (Intel 64 bit) to aarch64 (ARM 64 bit - Apple Silicon M1) and change any reference to ppcx64 to ppca64

FPC development version

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:

pascal
[]$ 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:

pascal
[]$ cd
     []$ cd fpc_main
     []$ git clean -f -d
     []$ git pull

To build and install FPC (the highlighted text should be all on one line):

pascal
[]$ 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:

pascal
[]$ 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):

pascal
[]$ 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:

pascal
[]$ 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:

pascal
[]$ 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:

pascal
[]$ cd fpc_fixes32
     []$ git clean -f -d
     []$ git pull

To build and install FPC (the highlighted text should be all on one line):

pascal
[]$ 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:

pascal
[]$ 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):

pascal
[]$ 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

Other installation options

See Other FPC Installation Options.

Testing the FPC Install

You might like to try a simple and quick test of FPC at this stage. From the command line (Mac - Open an Application > Utilities > Terminal) start an editor (e.g. pico or nano), paste this very short program and save it as the file helloworld.pas (using the WriteOut command in GNU nano):

pascal
program helloworld;
    begin
        writeln('hello world !');
    end.

Now exit the editor and compile this simple code by typing this command, before pressing ↵ Enter:

pascal
fpc helloworld.pas

It should very quickly make an executable called, you guessed it, "helloworld". Run this executable by typing this command and then pressing ↵ Enter:

pascal
./helloworld

If that worked, well done!

Useful command-line switches for compiling from source

Installing cross compilers

A cross compiler allows you to create binaries (executables) for a platform different from the platform being used for compilation. For example, working under macOS and creating executables for Win64 or Win32 (only up to and including macOS 10.14.6 due to Apple's removal of 32 bit frameworks). For details on how to do this, see Cross Compiling.

See also


From the Free Pascal wiki, page "Installing the Free Pascal Compiler", as the Internet Archive kept it on 2025-06-18, last changed on 2024-08-23. 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 4, last changed by WikiArchive .

Edited on wiki.freepascal.org by 13 people, 2020–2024

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
TrevInstalling the Free Pascal Compiler - extracted from the Installing Lazarus page
TrevLinux: Fix typos; remove entangled Lazarus info; update; fix wiki markup
TrevFPC binaries: Fix typo (minor)
TrevmacOS: Added details
DbannonTest FPC
DbannonAdded a brief intro.
TrevReinstate macOS content
TrevIntro -> Overview (minor)
TrevOverview: Fix typos (minor)
Dbannonmoved test
Dbannonmoved test fpc
TrevRearranged existing content (minor)
TrevFrom source on Windows: Fix intra-page link (minor)
TrevSee also: New section added
ZamronypjImprove installation instruction for FreeBSD using tar (minor)
ZamronypjFrom tar on FreeBSD
TrevFPC sources: Updated versions (minor)
TrevFrom source on Linux/BSD: Fix typo; update versions; disentangle Lazarus from FPC instructions (minor)
TrevFrom tar on FreeBSD: Reverted non-working changes (tested); updated to use FreeBSD fetch vs third party wget; fix wiki markup
TrevFreeBSD: Fix wiki markup (minor)
TrevFrom source on Linux/BSD: Fix typo; update architectures; fix wiki markup (minor)
TrevRe-organise FreeBSD sections; fix typos; fix intra-page links
TrevDisentangle Lazarus from FPC instructions; update versions; fix typos
TrevInstalling from source on Windows: Updated bootstrap compiler version now it is available; fix typo (minor)
TrevInstalling from source on Windows: Fix wiki markup (minor)
MischiOther macOS installation options: Add MacPorts
Mischifink & MacPorts: Update link
TrevOverview: Updated to add rpm files (minor)
DbannonSee also
DbannonSee also
TrevReverted edits by Dbannon (talk) to last revision by Trev (minor)
Dbannonupdated linux section
Dbannoncorrected linux dependencies
DbannonFPC binaries, note about RasPi
DbannonBreak tarball install into its own heading to make easier to find.
TrevOther macOS installation options: Demote headings (minor)
TrevFix syntax highilghting syntax (minor)
TrevSee also: Add trunk reference pages (minor)
TrevFreeBSD: Update note (minor)
TrevFPC sources: Added git usage
Dbannonmake a dir to to the install, easier !
ZamronypjInstalling from tar (minor)
Nickysn
TrevmacOS: Add note for Apple Silicon support
TrevmacOS: Apple Silicon note update (minor)
TrevmacOS: Fix link (minor)
ZamronypjInstalling from tar (minor)
ZamronypjInstalling from tar
ZamronypjAdd FreePascal installation on OpenBSD
AcmInstalling from the ports collection
TrevInstalling from the ports collection: Updated with linking issue fix
TrevInstalling from tar: Updated linker issue
TrevInstalling from the ports collection: Clarify (minor)
TrevInstalling from tar: Fix typo (minor)
TrevInstalling FPC binaries: Update
TrevInstalling an FPC release with the Windows installer: Change of title; text updates
TrevInstalling from source on Windows: Phase 1 of refurbishment ... in progress
TrevWindows: Fix heading levels (minor)
TrevWindows: re-adjust heading levels and titles
TrevInstalling an FPC release with the Windows installer: Add details of installer wizard process
TrevSource for a release version of FPC: Updated
TrevSource for a release version of FPC: Fix typo; expand Forum content
TrevInstalling an FPC release with the Windows installer: Remove WIP warning (minor)
TrevObtaining the source with the GUI TortoiseSVN client: Add WIP warning (minor)
TrevSource for a non-release version of FPC: Updated
TrevObtaining the source with the GUI TortoiseSVN client: Update in progress...
TrevObtaining the source with the GUI TortoiseSVN client: Updating in progress...
TrevObtaining the source with the GUI TortoiseSVN client: Updating in progress...
BartWindows: typo
TrevObtaining the source with the GUI TortoiseSVN client: New content
TrevSource for a non-release version of FPC: Remove refurbishment warning (minor)
TrevObtaining a bootstrap compiler: Add WIP warning (minor)
TrevSource for a non-release version of FPC: New content
TrevSource for a release version of FPC: Minor tweak (minor)
TrevSource for a non-release version of FPC: Fix typo (minor)
TrevObtaining a bootstrap compiler: Remove WIP warning (minor)
TrevCompiling the FPC source: Are we there yet?
TrevCompiling the FPC source: Fix typo (minor)
TrevCompiling the FPC source: Phase 2 complete
TrevmacOS: Move warning to top of page as its generic (minor)
TrevRelocate warning to top of page and make generic; minor tweaks (minor)
TrevSee also: Add links to FPC 3.2.0 User chnages and New features
TrevCompiling the FPC source: Tweaked Win64 cross-compiler text; fix typos (minor)
TrevSource for a non-release version of FPC: Added svn clean commands (minor)
TrevSource for a non-release version of FPC: Added cleanup command
TrevCompiling the FPC source: Add distclean to make args (minor)
TrevCompiling the FPC source: make commands consistent; add how to change environment variables
TrevCompiling the FPC source: Tweak cross-compiler instructions (minor)
TrevCompiling the FPC source: Position file inline (minor)
DbannonCorrected a prominent "Warning" that is quite wrong, needs to be moved in Windows secion or removed altogether.
TrevRemove warning pending better solution for combined package installers
TrevInstalling an FPC release with the Windows installer: Warning about also using the Lazarus installer
TrevmacOS: Add Warning about also using the Lazarus installer
TrevmacOS: Add warning; re-organise; add stub for installing from source
TrevInstalling from source: Expanded macOS content
DbannonNote about different way, link to Installing Lazarus
TrevFPC Fixes 3.2: Fix typos (minor)
TrevTesting the FPC Install: Add keypress template (minor)
OndrejFPC sources
OndrejFPC Tar Balls
Bi0T1NMention fpcupdeluxe directly in the overview as it is the most convenient way
Bi0T1NAdd some command-line switches for compiling from source
TrevRevert claim FPCUpDeluxe is the easiest way to install - not true
TrevStep 1: Download Xcode (optional): Make Xcode optional
TrevStep 2: Xcode Command Line Tools: cannot > does not (minor)
TrevmacOS: Updated for FPC git transition; some content moved to a template for reuse; some relocated to other options page
TrevmacOS: Remove Apple Silicon M1 note now that FPC 3.2.2 includes universal binaries
TrevOther installation options: Add period (minor)
MarcovDocumentation sources
AcmInstalling from the ports collection
AcmInstalling from the ports collection
TrevInstalling from the ports collection: Clean up wiki markup; update FPC header to v3.2.2 (minor)
TrevInstalling from tar: Update version numbers (minor)
TrevStep 2: Xcode Command Line Tools: update (minor)
Rfc1394add summary
Rfc1394
Barttypo (minor)
NickysnCompiling the FPC source: - make clean and make all should be separate commands in case of "make -jXXX" parallel compilation
Dbannonupdate tarball install to 3.2.2
DbannonFPC Tar Balls
TrevInstalling from source on BSD/Linux: Update current FPC version numbers (minor)
TrevInstalling from tar: Updated file locations and FPC version numbers
TrevInstalling from tar: Remove non-existent 3.3.1 (minor)
TrevSee also: Updated FPC version numbers (minor)
TrevSee also: Fix incorrect page link
Dbannonupdate version
Dbannonupdate fpc version number
DbannonFPC sources - looking to git
Dbannonget the source from git too.
Dbannontypo
Dbannonget syntax highlighting right !
Dbannonsome help for git
Dbannontypo
TrevWindows: Updated for Git; FPC 3.2.2, fixes_3_2 and main [TortoiseGit GUI to do]
JwdietrichTesting the FPC Install: Correcting sentence. (minor)
JwdietrichTesting the FPC Install: additional explanation.
JwdietrichTesting the FPC Install: more details for beginners added.
JwdietrichTesting the FPC Install: grammar fix.
TrevInstalling cross compilers: Updated
Dbannonnote about removing old FPC before installing a new one.
DbannonFPC Tar Balls
AlextppFPC sources Using Git or Zip: simpler show bash command lines
AlextppFPC Binary Packages: better topic name
AlextppFPC Tar Balls
AlextppFPC sources Using Git or Zip: better topic title
AlextppCompiling the FPC source
AlextppCompiling the FPC source
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppDownloading FPC sources from Git or zip
AlextppCompiling the FPC source
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppDownloading FPC sources from Git or zip
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AlextppCompiling the FPC source, using just downloaded FPC 3.2.2
AcmInstalling from the ports collection
AcmInstalling from the ports collection
AcmInstalling from the ports collection
Dbannondev versions of fpc

Talk about this page

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