Computing: Free Pascal Programming

Installing supplementary Lazarus/Free Pascal packages.


Linux users are well familiar with the concept of packages. These are software bundles, identified by a name and a version number, independent from other packages, except those, they depend on. A given version of a given Ubuntu package requires a minimal version of Ubuntu itself; older versions mostly continue to run on the new version of the operating system (backward compatibility). Packages largely contribute in having a correctly and smoothly running system:
  • The package installed will be the latest version, available for the actual operating system. Packages, that aren't compatible with the actual OS (in particular, because they are intended for a newer version) will not be installed.
  • When a new package is installed, all dependencies are normally also installed automatically. This ensures, that all what's needed to run the software correctly will be present.
  • Updating a package installs the best available version for the actual OS without affecting other (non-related packages). Dependencies will automatically be updated as needed.
As Linux, Lazarus is based on packages. The initial installation includes those features, that you need in everyday programming. Other features have been downloaded, but aren't actually part of the Lazarus GUI. If in Lazarus, you choose Packages > Install/Uninstall Packages, a window opens, showing you, which components are part of your installation and which you may directly install, by selecting them in the right pane of the window.
Lazarus packages: Install or uninstall a package (from the lists)
Lazarus packages: Installed and ready to install package lists
The Lazarus Online package manager.
"Online Package Manager(OPM) is a tool that automates the process of installing, upgrading, configuring Lazarus packages. The packages are stored in the main repository as zip files, along with a JSON file. The JSON contains all necessary information about the packages. On request the packages are downloaded, extracted, compiled, installed into the IDE. If available, it's also possible to update a previously installed package from the maintainer webpage". This is, how the Online package manager is described at the Free Pascal website. Here the link to the full document, with all details concerning the installation and usage of OPM.
Installing a package from those available to install, displays a list with all actual and new packages, showing if they are to be installed (new), kept or removed (what may happen for package compatibility reasons). The IDE will then be rebuild, and if all goes well, the new features will be parts of your Lazarus installation. The screenshot on the left shows the online package manager package installation list; the one on the right a common message, that you may get with new installs. The warning "The unit unit-name exists twice in the unit path of the IDE" results from the fact, that some unit is already present in the actual Lazarus installation, and is also present as part of your new installation files. I think, that you can safely ignore the warning, by pushing the "Ignore All" button.
Lazarus packages: Package list, as will be after the install of Online package manager
Lazarus packages: Redundant unit warning during the installation of a new package
Running the Online package manager.
After successful installation, the Online package manager may be launched from Package > Online Package Manager. A list of packages is displayed. Opening a given list entry shows all details about the package, in particular the installed and repository version, with the possibility to update to the latest release. For details, how to use the Online package manager, please use the link above to the corresponding page on the Free Pascal website.
Lazarus packages: Launching the Online package manager
Lazarus packages: Detailed package list in Online package manager
Manual installation of Lazarus packages.
You don't need to use the Online package manager to install Lazarus packages; you can also do it by downloading a Lazarus package file. This may be useful if you want to install the package, when being offline, if for some reason, you want to install an earlier version of the package, or if the package is some non-official third-party Lazarus extension (not available in OPM). When doing a manual installation of Lazarus packages, please keep in mind the following:
  • The best place to download Lazarus packages is the web version of the Lazarus Packages Repository. These packages are complete and up to date and should normally install without any problems. On the other side, I made the experience, that downloading a package, using the link on the Free Pascal Wiki or other official page, risks to end with a failure during the build, because there are some files missing in the download archive. Concerning third-party packages, there is, of course, no guarantee, that they install or function correctly.
  • The download should normally be a .zip archive, containing all files, necessary for installation. Unzip the archive to some folder, where Lazarus can access the files, during and (important!) also after installation. I actually use C:\Programs\Lazarus\packages. If Lazarus doesn't find a valid .lpk file, after a package has been installed, a "broken package" error message will be displayed.
  • The .zip archive sometimes contains several .lpk files. Please, read the package description, in order to be sure to choose the correct file. If you open a .lpk file in the IDE, and you have a "Compile", but no "Install" option (see below), the .lpk, that you chose, is not the one to be used.
  • The offline installation of a package may fail, because there are dependencies to download, what without Internet connection, isn't possible, of course.
To manually install a Lazarus package, unzip the download archive and open the .lpk file in Lazarus. This may be done in the IDE by choosing Package > Open Package File (.lpk) and browsing to this file, or by double-clicking the .lpk file. The package window opens. Choosing Compile is a good practice to see, if the archive is complete. To install the package, choose Use > Install.
Lazarus packages: Manual installation (by opening a .lpk file)
If supplementary packages are needed, the installer informs you, that they will automatically be installed; confirm, by pushing the "OK" button (screenshot on the left). Installing new packages makes necessary the rebuild of the Lazarus IDE; when asked for this, confirm by pushing the "Yes" button (screenshot on the right).
Lazarus packages: Confirmation of automatic install of supplementary package
Lazarus packages: Confirmation to rebuild the Lazarus IDE
The new feature (extension) is now part of the actual Lazarus installation. Where you can access it within the IDE depends on the package. We saw above, that the Online package manager appears as a new item in the "Package" menu. For the here used RichMemo package, a new icon is created in the "Common Controls" tab (screenshot below). Other possibility, as for for LNet, for example, a new tab with several icons is created.
Lazarus packages: New RichMemo icon in the Common Controls tab


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