Computing: Free Pascal Programming

Install Lazarus/Free Pascal on Manjaro and ArcoLinux.


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. The two Arch based distributions, referred to in this tutorial, Manjaro (Manjaro Linux 21.3.3 Ruah; German language version) and ArcoLinux (ArcoLinux 22.07.03; French language version) are really user-friendly and intended for everyone. To note, however, that I did not succeed to update the system on ArcoLinux; there is also a problem with the debugger in Lazarus...
Arch Linux uses pacman as package manager and the simplest way to install Lazarus on Manjaro and ArcoLinux is to do it in a terminal by entering the command
    sudo pacman -Sy lazarus
that installs (as you can see on the screenshot, taken on Manjaro) the whole bundle: the Lazarus IDE, the fpc compiler, the Free Pascal sources and the debugger.
Installing Lazarus on Manjaro: Terminal installation using 'pacman'
And here a screenshot of the entire installation process on ArcoLinux:
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
The screenshot shows the beginning of the installation on Manjaro.
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 (screenshot on the left: Manjaro; screenshot on the right: ArcoLinux). The Lazarus version installed in my case is Lazarus 2.2.4.
Installing Lazarus on Manjaro: The 'Configure Lazarus IDE' window
Installing Lazarus on ArcoLinux: The 'Configure Lazarus IDE' window
Rearranging and resizing the IDE windows is lots smoother than on most other Linux systems, but a new issue when building an application: Two warning messages, telling that crtbeginS.o not found and crtendS.o not found (the screenshot has been taken on Manjaro; the same problem exists on ArcoLinux). 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 Manjaro: 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 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 are 12.2.1 on Manjaro (after system update) and 12.1.0 on ArcoLinux (original ISO distribution version, system update having failed).
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
and here 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
The screenshot below shows fpc.cfg opened in Mousepad on Manjaro. 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 (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 on both systems. However, whereas on Manjaro, the execution of the application from within Lazarus worked fine, on ArcoLinux, a window popped up saying that there has been a Debugger error and it was not possible to run the application.
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.

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