Lazarus is a free cross-platform visual integrated development environment (IDE) for rapid application development using the Free Pascal compiler.
The purpose of this article is to explain how to cross compile for ARMv7 an application written in Pascal using the Lazarus IDE.
On Ubuntu 18.04, The following command can be used to install the needed dependencies:
$ sudo aptitude install make binutils build-essential gdb subversion zip unzip libx11-dev libgtk2.0- dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev
fpcupdeluxe is a tool that can be used to install multiple versions of FPC and Lazarus in an easy way.
Download the most recent version of fpcupdeluxe from here, give it executable permissions and run it on your host machine.
$ chmod +x fpcupdeluxe-x86_64-linux $ ./fpcupdeluxe-x86_64-linux
Select the version for both FPC and Lazarus then click on the install button. The following image represents a successful installation log:
Next, select the CPU and the OS for the compiler on the Cross tab, in this case we will choose the arm CPU and the linux OS. Finally, press the Install compiler. Below is an image representing a successful installation log:
A Lazarus executable should have been created on your computer home directory, to open the Lazarus IDE just run it:
$ cd ~ $ ./Lazarus_fpcupdeluxe
For configuring the compiler options, go to Project -> Project Options -> Compiler Options -> Config and Target and change the fields on the Target platform topic, see below:
After compiling your program, you can check if everything went well using the file command:
$ file project1 project1: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.0.0, not stripped