Freepascal and Lazarus installation on RPi

freepascal logo
A page describing how to get the latest Freepascal and Lazarus development systems on the Raspberry Pi in optimal format, targeted at ARMV6 (all Raspberri Pi’s) and ARMV7 (RPi 2).

Updated March  2020, for current FPC/Lazarus/Raspbian versions.

The easy method, not recommended

sudo su
apt-get install fp-compiler
apt-get install lazarus

On Raspbian wheezy you get Freepascal 2.6.0 and Lazarus version dating from 2012. Working but not quite bleeding edge. Perfect for a first session!

On Raspbian jessie you get more recent versions: Freepascal 2.6.4 and Lazarus 1.2.4.
Note that for me Lazarus did not show up in the Programming menu on the desktop on jessie, but easy to add yourself with the menu editor (Lazarus is located somewhere in /usr/local/). Freepascal is missing the character based fp IDE alas. And the programs compiled on the Raspberry Pi 2 B crashed on the older Raspberry Pi for me. So far so good for most of us. But not what I wanted. I have both Raspberry Pi’s Version 1 and the newer Version 2 systems. All systems run Lazarus on the desktop, but the older version 1 systems are running Lazarus quite slow due to the ARM V6 CPU and lack of memory. But the resulting programs are running fast enough, we have a real compiler here!

On Buster you get even more recent versions. Alas the package maintainers did a not perfect job, much is not working …

Install pre-compiled .deb’s

Lazarus forum post for discussion and .to download deb packages using the following Wiki article.

You may have to install some dependencies libgtk2.0-dev libgpm-dev libncurses-dev

sudo apt install libgtk2.0-dev libgpm-dev libncurses-dev

sudo dpkg -i fpc-laz_3.0.4_armhf.deb
sudo dpkg -i fpc-src_3.0.4_armhf.deb 
sudo dpkg -i lazarus-project_2.0.6-0_armhf.deb

To add packages: increase swap file to 1000 MB (see below)!

Wiki article to get fpc3.04 and Lazarus 2.06  deb packages on Raspbian Buster RPI 4 as build machine

You may get a few linker messages, like crtbegin.0 missing. Harmless but annoying.

Get rid of them with

sudo apt-get install libgcc-8-dev

and add this line to /etc/fpc.cfg

# path to the gcclib

Now the -T warning is also harmless, bug in LD and the trunk version of FPC seems to have a solution. .

Install from source

Tutorial: Installation of Lazarus to Raspberry Pi 3 + 4
written by Linkat Version: 16.08.2019

Using 2019-07-10-raspbian-buster

1. Download:
(or use the newer releases)

2. Install the libs:
sudo apt-get install libgtk2.0-dev libghc-x11-dev -y

3. Unpack fpc-3.0.4.arm-linux-eabihf-raspberry.tar, and (PCmanFM “Extract Here”)

4. Move the extracted folders as root:
sudo mv fpc-3.0.4.arm-linux/ /usr/local
sudo mv fpc-3.0.4/ /usr/share
sudo mv lazarus/ /usr/lib

5. Installation of fpc
Start the terminal and cd /usr/local/fpc-3.0.4.arm-linux
“sudo ./”

Answer the questions:
Install prefix -> /usr
the next 4 questions by “Yes”
Now the Free-Pascal-Compiler should be installed.

6. Now cd /usr/lib/lazarus
with “sudo make clean bigide” you can build the Lazarus-IDE.
(this needs abt. 10 min)
then you can start with “./startlazarus”

Older methods, outdated, may still be of value due to optimized RP1 1 Zero etc. compiler.

The easy method

precompiled versions at! This will give you the latest (as of January 2016 this will be FPC 3.0.0 and Lazarus 1.7) precompiled versions, which can be used alongside system wide installations The builds are for ARMV6, so executables will run on all Raspberry Pi’s. Just a simple script to download and execute! Note that this is not the bigide, you may have to compile more packages.

The script delivers an icon for Lazarus on the desktop. The Freepascal terminal icon does not work, but the underlying script does, ~/Development/FreePascal/fpc/bin/ in a console to make fpc available.
Note the (harmless) crtbegin.o warning in Lazarus, a solution is described later in this article.

Using the Debian method

Install from source

What I really want is:

  • compile and test on the Raspberry Pi 2 and 3 and enjoy the speed.
  • Run on all Raspberry Pi models, so limited to ARMV6.
  • Run on older wheezy and modern jessie Raspbian.
  • The RPi 2, 3 have four ARM V7 cores, Freepascal and Lazarus will benefit in speed from this architecture if compiled for ARMV7.

So I set out to build images of Raspbian with more current versions of Freepascal and Lazarus on both latest Raspbian jessie and wheezy.

Some opening remarks:

  • Newer versions of FPC and Lazarus appear regular,  you may substitute those newer versions in the recipes.
  • Recipe for ARM V6 RPi versions 1 and 2 Model A, A+, B, B+, 2B, Zero
  • Recipe for ARM V7  version 2, 3 Model B

Building any version of Freepascal from source requires a seed compiler. For the current version (july 2016) this is version 3.0. This is available as binary for ARM,  a generic version, from, not from the official distributions.

The trick in building Lazarus  is making sure the Freepascal compiler is targeted for the same architecture, so first we have to build a Freepascal compiler for the same architecture.

The following steps are my steps, after a lot of reading and experiments, to get fpc and Lazarus in folders of user pi.
On the bottom of this pageyou will find a recipe by rvk, nearly identical but leading to a system wide installation in /usr/local.

Setup a fresh system

First a fresh system, get the latest jessie and/or wheezy from These are the steps I perform for a new system. I do most work from my desktop PCere, including remote access via SSH and xRDP to the Pi’s.

Image SD card (Win32DiskImager), 16GB minimal. 8 GB may work, but I often get problems with installing Lazarus due to out of disk space.

Boot and login (user pi, password raspberry) locally

With raspi-config at least change

  •  Expand file system
  •  Boot into commandline (desktop is in the way during the build!)
  • Change password
  • Overclock (medium for older, high for RPi 2B, n.a. for RPi 3)
  • Advanced options:
  •  enable ssh
  •  memory split to 16 MB, you may change that back later for graphics work
  •  change hostname and reboot

A fixed Ethernet connection is recommended. Wifi will work,  see my other pages how to install/configure that.

Get the IP address assigned to the Pi.



and note the IP address assigned to the RPi. Now you can use PuTTY or other SSH client from your desktop to access the command line of your Pi or continue on the RPi itself. The advantage of working via SSH is obvious, you can copy for this webpage and paste (right mouse click) into PuTTY.

Make some room,

Software I do not intend to use at all and take up a lot of disk space

sudo su
apt-get -y remove --purge oracle-java8-jdk openjdk-7-jre oracle-java7-jdk openjdk-8-jre
apt-get -y purge libreoffice*
apt-get -y autoremove 
apt-get -y clean 
df -h 

Get an update system and get subversion, unzip and libraries for Lazarus

apt-get update
apt-get upgrade
apt-get install -y subversion unzip
apt-get install -y libgtk2.0-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libatk1.0-dev libghc-x11-dev
apt-get install -y libx11-dev libgdk-pixbuf2.0-dev  gir1.2-coglpango-1.0  xorg-dev 

Increase swapfile to prevent ‘out of memory’ during compilation

change the line in dphys-swapfile the size from 100 to 1000 and check it is 1000M now. Remember to cut that back to the default after the builds!
nano /etc/dphys-swapfile
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
ls -lh /var
exit (from su)

Build Freepascal

July 2016: this will be trunk FPC 3.1.1. Substitute if newer.

Get seed compiler fpc 3.0. installed  (from, must be run in user mode, so leave SU. On current Raspbian (March 2020)  apt-get update fpc

mkdir /home/pi/Development
cd /home/pi/Development
tar xvf fpc-3.0.0.raspberry-min.tar.gz
chmod +X
rm /home/pi/Development/fpc-3.0.0.raspberry-min.tar.gz
rm /home/pi/Development/fpc-3.0.0.tar.gz

Do not install/start this seed compiler, we will use it only to compile fpc trunk.

For Lazarus 1,8 you will need FPC 3.04

From the forum by RvK:

Question is, is there any 3.0.4 version fpc minimal compiler available for Raspberry Pi platform?

 No, there is not. (at least not officially)

There is also no bootstrap fpc version 3.0.4. For some reason they refused to make one. (not sure of what the exact reason is again)

You can “just” download FPC 3.0.4 and use ppcarm from it. (It’s a 52MB download just to use ppcarm :( )
You don’t need to install this version. Just extract it all and use it with the PP option:

make all install OPT=$OPTIONS PREFIX=$BASE/fpc PP=$BASE/compiler3/lib/fpc/3.0.4/ppcarm
(where $BASE/compiler3 is where I unpacked the tar and $BASE is where I want the installation of fpc and Lazarus)

Get fpc 3.0 sources (you might check trunk for the latest)

md /home/pi/fpc-3.1 
cd /home/pi/fpc-3.1 
svn co source 
cd source 


make clean all install OPT=-dFPC_ARMHF INSTALL_PREFIX=/home/pi/fpc-3.1 PP=/home/pi/Development/fpc-3.0.0/bin/ppcarm 


make clean all install OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" INSTALL_PREFIX=/home/pi/fpc-3.1 PP=/home/pi/Development/fpc-3.0.0/bin/ppcarm
rm -f "/home/pi/fpc-3.1bin/ppcarm"
ln -sf "/home/pi/fpc-3.1/lib/fpc/3.1.1/ppcarm" "/home/pi/fpc-3.1/bin/ppcarm"
rm -f ln /home/pi/fpc-3.1/share/fpcsrc
ln -sf /home/pi/fpc-3.1/source /home/pi/fpc-3.1/share/fpcsrc
(used to be) /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PPC_CONFIG_PATH=/home/pi/fpc-3.1/bin
(add this to the default user settings in /home/pi/.profile
cd /home/pi/fpc-3/1/bin
./fpcmkcfg -d basepath=/home/pi/fpc-3.1/lib/fpc/3.1.1/ > fpc.cfg
nano /home/pi/.fppkg/config/default
change line GlobalPrefix=/home/pi/fpc-3.1
copy fpg.cfg from the bin folder  to the home directory .fpc.cfg
Add the fpc bin path to the path in the home directory, 
nano /home/pi/.profile


Get the source from svn

Check what is available at

mkdir /home/pi/lazarus
cd /home/pi/lazarus
svn co source
cd source 
sudo su
make all 
make bigide

make install 

Now continue with the Post build steps.

Set swapfile to default

nano /etc/dphys-swapfile
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
ls -lh /var

change back from 1000 to 100 and check its 100M now.

Use raspi-config to set the memory split back to 64 or higher, depending on your usage.

Fixing the GCC Library path

Locate crtbegin.o using (jessie june 2016)

sudo find / -name crtbegin.o

For jessie may 2016 it is in /usr/lib/gcc/arm-linux-gnueabihf/4.9

nano /home/pi/fpc-3.1/lib/fpc/3.1.1/fpc.cfg

Change the line

# path to the gcclib


# path to the gcclib

Copy the fpc.cfg also to /pi/home.fpc.cfg to be sure.

Start Lazarus

You can start Lazarus from the desktop


With jessie the Lazarus entry did not appear in the menu programming. Add this yourself with the Menu editor, browse the computer to find the startlazarus executable , the desktop icon is there also in the folders.

Lazarus asks the first time run where the fpc sources are. I did not perform ‘make sourcefiles’ so this will do:


Now you are ready to run!

Resources from which I learned how to write the steps above! Thank you!

Scripted steps by rvk

Found in
Leads to fpc and Lazarus system wide in /usr/local

# ======================================================
# Based on clean 2016-05-27-raspbian-jessie.img
# Total install time: 38 minutes (from complete scratch)
# by rvk (v.1.1, 2016-07-08)
# ======================================================

# ======================================================
# first some essentials (5.5 minutes)
# ======================================================
sudo -i
apt-get update
apt-get upgrade -y
apt-get autoremove
apt-get autoclean
# ======================================================
# install remote descktop serveer for rdp session win10
# only neede is headless RPI (1 minute)
# ======================================================
sudo apt-get -y install xrdp
sudo nano /etc/xrdp/xrdp.ini
bitmap_compression: no   # <-- change this line
# ======================================================
# some other essentials (2 minutes)
# ======================================================
sudo apt-get -y install build-essential p7zip-full subversion
sudo apt-get -y install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev

# ======================================================
# we NEED to extend the swapfile (1 minute)
# ======================================================
sudo nano /etc/dphys-swapfile
CONF_SWAPSIZE=512   # <-- change this line
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

# ======================================================
# if you're not on raspbian-jessie this could work too
# ======================================================
# dd if=/dev/zero of=/path/to/swapfile bs=1M count=512 # For 512MB swap file
# mkswap /path/to/swapfile
# swapon /path/to/swapfile

# ======================================================
# install fpc and lazarus trunk (total 28.5 minutes)
# ======================================================
sudo -i

# ------------------------------------------------------
# first fpc
# ------------------------------------------------------
mkdir /usr/local/fpc
cd /usr/local/fpc

# ------------------------------------------------------
# We need a bootstrap compiler fpc 3.0.0 (2.5 minutes)
# There is NONE AVAILABLE so we need to download complete
# fpc-3.0.0.arm-linux-raspberry1wq.tar
# ------------------------------------------------------
tar xvf fpc-3.0.0.arm-linux-raspberry1wq.tar
cd fpc-3.0.0.arm-linux
tar xvf binary.arm-linux.tar
tar zxvf base.arm-linux.tar.gz
cd ..

# ------------------------------------------------------
# checkout fpc trunk (3 minutes)
# ------------------------------------------------------
svn co trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile fpc trunk (11 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF" PP=/usr/local/fpc/fpc-3.0.0.arm-linux/lib/fpc/3.0.0/ppcarm

# ------------------------------------------------------
# install fpc trunk (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local PP=/usr/local/fpc/trunktmp/compiler/ppcarm
rm /usr/local/bin/ppcarm
rm /usr/local/bin/sameplecfg
ln -sf /usr/local/lib/fpc/3.1.1/ppcarm /usr/local/bin/ppcarm
ln -sf /usr/local/lib/fpc/3.1.1/samplecfg /usr/local/bin/samplecfg
make install sourceinstall OPT="-dFPC_ARMHF" PREFIX=/usr/local
rm /usr/share/fpcsrc
ln -sf /usr/local/share/src/fpc-3.1.1/fpc /usr/share/fpcsrc

# /usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/3.1.1 -o /usr/local/bin/fpc.cfg
# this doesn't seem to work correctly ???

samplecfg /usr/local/lib/fpc/3.1.1 /etc
# Running on linux
# Write permission in /etc.
# Writing sample configuration file to /etc/fpc.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.ini
# Writing sample configuration file to /etc/fppkg.cfg
# Writing sample configuration file to /etc/fppkg/default

# ------------------------------------------------------
# then Lazarus
# ------------------------------------------------------
mkdir /usr/local/lazarus
cd /usr/local/lazarus

# ------------------------------------------------------
# checkout lazarus trunk (1.5 minutes)
# ------------------------------------------------------
svn co trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile lazarus trunk  (6.5 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF"

# ------------------------------------------------------
# install lazarus trunk  (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local

# ------------------------------------------------------
# remove menu-cache to make Lazarus visible in menu
# ------------------------------------------------------
exit  # from sudo
killall lxpanel
find ~/.cache/menus -name '*' -type f -print0 | xargs -0 rm
exit  # from pi

# ------------------------------------------------------
# connect on Windows via Remote Desktop Connecton (mstsc.exe)
# user pi password rapberry
# Menu > Programming > Lazarus
# create small test-project and run
# ------------------------------------------------------

# ======================================================
# note: recompiling lazarus as use pi
# will create a working copy under ~/.lazarus/bin
# ======================================================