Computing: Free Pascal Programming

Installing Lazarus/Free Pascal on Arch Linux based systems.

Arch Linux has the reputation to be rather tough to work with and is thus not recommended to computer newbies. What is (perhaps) true for the original mustn't be the case for distributions that are based on it. Arch Linux based distributions like Mabox Linux (in this tutorial: Mabox Linux 23.12 Istredd) and Manjaro (in this tutorial: Manjaro Linux 21.3.3 Ruah; German language version) are really user-friendly and intended for everyone. With ArcoLinux (ArcoLinux 22.07.03; French language version), I did not succeed to update the system; there is also a problem with the debugger in Lazarus. Open Mandriva (Open Mandriva 23.08 Rome) installed correctly, but did not boot anymore after I updated the system; same problem after the installation of Lazarus. These issues may be VMware related and not occur on physical hardware or with other virtualization software.

Lazarus/FPC on ArcoLinux.

Arch Linux uses pacman as package manager and the simplest way to install Lazarus on ArcoLinux is to do it in a terminal by entering the command
    sudo pacman -Sy lazarus
that installs the whole bundle: the Lazarus IDE, the fpc compiler, the Free Pascal sources and the debugger.

Installing Lazarus on ArcoLinux: Terminal installation using 'pacman'

Installation without any issues, but bad surprise when wanting to start the IDE: there is no launch shortcut and no start-lazarus or lazarus-ide terminal program available! No reason to panic: It's not that something went wrong, but just that something is missing: You'll have to install the lazarus-gtk2 package:
    sudo pacman -Sy lazarus-gtk2

Installing Lazarus on ArcoLinux: Install of the 'lazarus-gtk2' package

With the lazarus-gtk2 package installed, there will be a launcher in the Development group of the Start menu and the Configure Lazarus IDE window, that is displayed the first time Lazarus is launched, shows that all components have been found and work correctly. The Lazarus version installed in my case is Lazarus 2.2.4.

Installing Lazarus on ArcoLinux: The 'Configure Lazarus IDE' window

Rearranging and resizing the IDE windows is smoother than on most other Linux systems, but a new issue when building an application: Two warning messages, saying: crtbeginS.o not found and crtendS.o not found. These are warnings and not errors and my application was actually build correctly. However, the two messages also say that "this will probably cause a linking failure" and even if it didn't in this case, it probably would in others. Thus, all reasons to try to find a solution for this problem.

Installing Lazarus on ArcoLinux: gcc related warning messages when building an application

The problem with crtbeginS.o and crtendS.o is related with gcc and is rather common on Linux systems. The Free Pascal configuration file /etc/fpc.cfg contains the path to the gcc files in /usr/lib/gcc, that contains a subdirectory (in the case of ArcoLinux it is called x86_64-pc-linux-gnu), that itself contains a subdirectory (sometimes there are several) that has the name of the version of the actually installed gcc package. Thus, if the version referred to in fpc.cfg does not match the version of the installed gcc, we get an invalid path and some files needed for the build cannot be found.

Not difficult to solve the problem: Just browse to /usr/lib/gcc/x86_64-pc-linux-gnu and look up how its subdirectory is called (if there are several subdirectories, choose the one with the most recent version name, but be sure to check if it contains crtbeginS.o and crtendS.o) and change the gcc related paths in fpc.cfg. In my case, the version referenced in fpc.cfg was 12.2.0, and the installed version of gcc is 12.1.0.

Here the correct gcc settings in fpc.cfg for ArcoLinux 22.07.03:
    # path to the gcclib
    #ifdef cpui386
        -Fl/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/32
    #endif
    #ifdef cpux86_64
        -Fl/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0
    #endif

After I had modified fpc.cfg, my BlackJack2 application was built without any error messages displayed. However, when I tried to run the application, a window popped up saying that there has been a debugger error and the application did not start.

Installing Lazarus on ArcoLinux: Debugger error when running an application from within the IDE

I have not figured out what's the reason of this problem and what can be done to fix it. Execution of the application is possible despite of the issue, by using the command Run > Run without debugger. This is fine for me, especially I develop nearly exclusively on Windows. For people, who are used to work with the debugger, it's a real problem of course, and even if you normally do not use it (as is the case for me), there are situations during the program test phase, where the error information displayed is lots more meaningful if the debugger is active. If someone knows how the problem can be fixed, thanks for sending me an email.

Lazarus/FPC on Mabox Linux.

Mabox Linux is fast without needing lots of resources, it's easy to install, highly configurable, aesthetically well done and extremely user-friendly. To install Lazarus, just choose Install popular apps from the Welcome screen, select the Development category, and browse for Lazarus.

Installing Lazarus on Mabox Linux: Installation using the 'Install popular apps' GUI application

The Lazarus launcher becomes available in Applications > Development. When launched for the first time, the Configure Lazarus IDE pops up, indicating that there is a problem with the debugger. Easy to fix: choose Debugger in the left pane, and in the right pane, select the create a new recommended backend radiobutton. Then push the Start IDE button. In my case, it's the brand-new Lazarus 3.2 that has been installed.

Installing Lazarus on Mabox Linux: Creating new recommended backend for the debugger

The build of my BlackJack2 application succeeded without any problems (screenshot), as did its execution.

Installing Lazarus on Mabox Linux: Building a GUI application

Lazarus/FPC on Manjaro Linux.

The installation and issues on Manjaro are very similar to those on ArcoLinux. Installation is done using pacman:
    sudo pacman -Sy lazarus

Installing Lazarus on Manjaro: Terminal installation using 'pacman'

As on ArcoLinux, you'll have to install the lazarus-gtk2 package:
    sudo pacman -Sy lazarus-gtk2

Installing Lazarus on Manjaro: Install of the 'lazarus-gtk2' package

With the lazarus-gtk2 package installed, there will be a launcher in the Development group of the Start menu and the Configure Lazarus IDE window, that is displayed the first time Lazarus is launched, shows that all components have been found and work correctly. The Lazarus version installed in my case is Lazarus 2.2.4.

Installing Lazarus on Manjaro: The 'Configure Lazarus IDE' window

An issue, however, (the same as on ArcoLinux) when building an application: Two warning messages, telling that crtbeginS.o not found and crtendS.o not found. These are warnings and not errors and my application was actually build correctly. However, the two messages also say that "this will probably cause a linking failure" and even if it didn't in this case, it probably would in others. Thus, all reasons to try to find a solution for this problem.

The problem with crtbeginS.o and crtendS.o is related with gcc and is rather common on Linux systems. The Free Pascal configuration file /etc/fpc.cfg contains the path to the gcc files in /usr/lib/gcc, that contains a subdirectory (in the case of Manjaro and ArcoLinux it is called x86_64-pc-linux-gnu), that itself contains a subdirectory (sometimes there are several) that has the name of the version of the actually installed gcc package. Thus, if the version referred to in fpc.cfg does not match the version of the installed gcc, we get an invalid path and some files needed for the build cannot be found.

Not difficult to solve the problem: Just browse to /usr/lib/gcc/x86_64-pc-linux-gnu and look up how its subdirectory is called (if there are several subdirectories, choose the one with the most recent version name, but be sure to check if it contains crtbeginS.o and crtendS.o) and change the gcc related paths in fpc.cfg. In my case, the version referenced in fpc.cfg was 12.2.0. And the installed version of gcc actually is 12.2.1 (after system update).

Here the correct gcc settings in fpc.cfg for Manjaro Linux 21.3.3:
    # path to the gcclib
    #ifdef cpui386
        -Fl/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/32
    #endif
    #ifdef cpux86_64
        -Fl/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1
    #endif

The screenshot below shows fpc.cfg opened in Mousepad. Note, that the text editor is actually executed with super-user privileges. This (convenient, but also dangerous) possibility is given by a feature available in the context menu of the file manager Thunar: Instead of opening /etc by double-clicking it, right-click on the folder and choose Thunar Root. This is similar to using sudo in the terminal in the sense that all actions you will take, will be executed as root, in particular if you open a file, it will be opened as root and you can modify it and directly save it back to its original location, even if this is a system directory (I hope that you are aware of the danger using this feature).

Installing Lazarus on Manjaro: Adapting /etc/fpc.cfg in the Mousepad text editor

After I had modified fpc.cfg, my BlackJack2 application was built without any error messages displayed. The debugger problem encountered on ArcoLinux did not manifest on Manjaro (maybe because of the update that succeeded here, but failed on ArcoLinux?).

Lazarus/FPC on Open Mandriva.

On Open Mandriva, you can install software packages in a terminal using dnf:
    sudo dnf search lazarus
    sudo dnf install lazarus

Installing Lazarus on Open Mandriva: Terminal installation using 'dnf'

I have no idea if it works. In fact, after installation, I restarted the computer and the system did not boot anymore (I got nothing but an entirely black screen). This has nothing to do with Lazarus; the same happened when I tried to update the system, and I suppose would also happen with other software. From the past I know that Open Mandriva has problems with running on VMware Workstation, and I suppose that that's actually the issue here. So, if you use VMware, do not try to install Lazarus on Open Mandriva, or better, do not use Open Mandriva!


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