Computing: Free Pascal Programming

Installing Lazarus/Free Pascal on Linux.


Concerning this document, please note the following:
  • Linux is not Linux; there are lots of operating systems grouped under this name, but that are very different from each other in their way to work, to use and how to do to install software. This text applies to Ubuntu, the version used in the tutorial being 18.04 LTS; some details concerning the more recent version 20.04 LTS and the older version 14.04 LTS (used as base for BioLinux 8 and SemiCode OS 1.0, for example) are given at the end of the document. Click the following link for details about other Debian (Devuan or Ubuntu) based systems, and the following one for details about Arch Linux based systems. Concerning other Linux distributions, this site contains information on how to proceed to install Lazarus/FPC on openSUSE, on Fedora, on CentOS, on PCLinuxOS, on Solus, on EndeavourOS, on Void Linux, on ALT Linux, and on NixOS.
  • Linux software is organized in packages, a given version of the operating system awaiting a given version of the applications, to be installed on it. The big advantage of this feature is that all fits well together and normally runs smoothly and without any problems. The disadvantage is that it's often tricky (or even impossible) to install a given version (for instance the most recent) of a given software package on a given version of the OS. Thus, downloading the last version of Lazarus and trying to install it may need to install several dependencies first and even if you succeed with the install, building your projects may fail (e.g. with the linker aborting with an error message such "unrecognized relocation 0x2a in section .text").
  • The simplest way to install Lazarus on a Debian based system, is using the command line program AptGet. First, AptGet downloads the version of Lazarus being known to work with the current OS version. Second, it resolves, downloads and installs all dependencies in order to be able to correctly run a given software package.
Installing Lazarus on Ubuntu 18.04 LTS.
First, you should update the package list for your operating system. Open a terminal and type:
    sudo apt-get update
Preceding a command by "sudo", gives you superuser (root) rights (and you will have to enter your Ubuntu user's password). apt-get is the name of the AptGet command line program. The parameter "update" tells "aptitude" to update the package information.
Aptitude: Updating the package list
To install a given package, you need to know the exact package name. Use one of the following commands to search for a package name:
    apt-cache search <search_term>
    dpkg -l *<search_term>*
Both commands list all available packages whose name or description contains <search_term>. The second one also shows whether a package is installed on your system by marking it with "ii" (installed) or "un" (not installed). A detailed description of apt-get may be found in the AptGet HowTo of the Ubuntu Community Help Wiki.
To install Lazarus 1.8 on Ubuntu, type the following in the terminal:
    sudo apt-get install lazarus-1.8
AptGet lists all new packages to be installed, as well as those that have to be upgraded, those that have to be removed and those that could optionally be installed. Answering "y" (default option) to the question "Do you want to continue?" will launch the download and install process, all automatically and when finished, your new Lazarus should be installed and ready to use.
Aptitude: Packages to install/upgrade
Aptitude: Packages download
Aptitude: Packages installation
The installation process has created a shortcut to start the Lazarus IDE. You'll find it by clicking the "Applications" icon in the favorite bar of the Ubuntu dash and then searching for Lazarus. The version actually installed on my system is Lazarus 1.8.2 (64bit).
Shortcut to launch the Lazarus IDE
Exactly as on Windows, when starting Lazarus for the first time, a window pops up, where you may configure it, i.e. set the paths to compiler, make, debugger.... Check if all components have been found; this should normally be the case.
Lazarus components configuration
After pushing "Start IDE", Lazarus opens with a new "application" project. You may want to rearrange the different windows present and add other ones (using the "View" menu). Object Inspector, Source editor and Messages windows should always be visible and easily accessible.
The Lazarus IDE with a new project opened
Installing Lazarus on Ubuntu 20.04 LTS.
With the actual (January 2022) LTS version, AptGet installs Lazarus 2.0.6. I encountered some problems, no idea if due to the new Ubuntu version, to the installed Lazarus version, or to the fact that I run Ubuntu on a VMware virtual machine.
  • When launching the application, the message "StartLazarus-2.0.6" is not responding pops up. Just push the Wait button, or do nothing: After some time the IDE starts up.
  • I did not succeed in arranging the GUI windows as I wanted. In fact, they resized by themselves when I tried to make them use the whole screen width. Simple work-around: Running Lazarus in single window layout. This option becomes available by installing the anchordockingdsgn package, included in the Lazarus download (but not automatically installed). If you are not familiar with Lazarus packages, you may want to take a look at my Installing supplementary Lazarus packages tutorial.
Installing Lazarus on older versions of Ubuntu.
As I said above, trying to install the most recent version of a software package on an older Linux operating system may be tricky and even impossible. The simplest way is just to use the package with the version expected by the OS. And on Ubuntu, the simplest way to be sure that all dependencies are installed and upgraded without breaking other dependencies, is to use AptGet.
Installing Lazarus on my Bio-Linux 8 (based on Ubuntu 14.04 LTS) with the command
    sudo apt-get install lazarus
set up Lazarus version 1.0.10. An old version of course, but running properly and properly building several of the projects that I developed with Lazarus 1.8.4 on Windows 10. For others, some changes of the code are necessary, because, for example, the properties and methods of a given object do not exist (or are differently called) in the old Lazarus version.
Write once, compile anywhere?
This is what Lazarus and Free Pascal strives for. The reality seems to be somewhat different. I had no problems to build the projects, developed on Windows on Ubuntu, but running them was not always possible resp. produced an unproper output. I suppose that some units, working on Windows, do not work on Linux and I also suspect that some objects and methods (especially when used with default settings) behave differently. Thus, if you intend to develop Lazarus applications intended to run on several platforms, be sure to have a closer look at related articles in the Lazarus/Free Pascal documentation, as well as testing them on all the platforms to be considered.


If you find this text helpful, please, support me and this website by signing my guestbook.