Computing: Free Pascal Programming

Programming Home   Home   Contact

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 on them. This text applies to Debian based systems (such as Debian, Ubuntu and Linux Mint for example); installation on other Linux systems (SuSe, Fedora, Mandriva...) may be completely different!
  • 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 disadvantge 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 lauch 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 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 wihout 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 the projects (at least most of them) that I developed with Lazarus 1.8.4 on Windows 10.
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 unpropper 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.