Installing FastReport in Lazarus

This article is outdated. Updated information is available at the following link.

As part of the Academic's educational programme, we have decided to produce some support articles for students.

If you are making business or government software that needs to be cross-platform or just run on Linux systems or native operating systems (which are also Linux), you will eventually need to create and output electronic documents, print receipts or some format (PDF, office, HTML, etc.). And we with our FastReport VCL product will be glad to help you with all this!

Installing FastReport in Lazarus

Let's start with the actual installation of Lazarus.

First we need to install the software for our own operating system.

Installing Lazarus for Windows

The first thing to do is to download the Lazarus installation package from the official website and select the bit-type of your system.

Installing FastReport in Lazarus

For Windows, the Lazarus installer is a single .exe file and should be no problem.

Next we download the right version of the archive from the official website .

Installing Lazarus for Windows

From the downloaded archive copy the contents to C:Windows\System32 and C:Lazarus, then reboot Windows. After starting Lazarus, it prompts you to configure it immediately. You just have to press ok and agree with the default settings.

Installing Lazarus for Linux

Like in Windows, the first thing you should do is download the Lazarus installer package from the official website 

Installing Lazarus for Linux

Each item in this list consists of 4 files (3 installer packages and a text file).

- The Lazarus(project) installer package;
- The fpc-src installer package;
- fpc(laz) installation package;
- README.txt file.

It is important to install them in the right order. First fpc(laz), then fpc-src and lastly Lazarus(project).

Let's fix the problem with fonts beforehand. All operating systems have fonts that are set by default. For example, Arial is the default font in both Windows and, say, Ubuntu. But the default Arial in Ubuntu is not actually the same Arial in Windows, which means that text reports made with Windows Lazarus will look awful in Linux Lazarus (and vice versa).

To avoid this we will at least install in Linux the same fonts as in Windows.

For Ubuntu you can do this with:

sudo apt-get install msttcorefonts

But for other Linux distributions the command may be different.

Next, the following packages need to be installed for SqLite to work properly: sqlite3, libsqlite3-dev

More details can be found here. 

For Ubuntu you can do this with:

sudo apt-get install sqlite3 libsqlite3-dev

Launch Lazarus, where it prompts you to configure it. Click 'OK' to accept the default settings.

Installing FastReport packages in Lazarus for Linux / Windows

We have already installed Lazarus, so now we can install the FastReport VCL package in Lazarus. In order to do that we need to download and unzip the package from the official website. In contrast to Embarcadero Delphi, RAD Studio and C++ Builder where it is sufficient to "just install the compiled component packages", in Lazarus you have to compile them.  To install packages click Package -> Open Package File .lpk, select the package in the file manager and the following screen will appear:

Installing FastReport packages in Lazarus for Linux / Windows

In it, click Compile, wait for the compilation to finish and then click Use. Lazarus will reboot after each package is installed.

Moving on to the order in which FR packages are installed:

1. fast-script\Source\fs_lazarus.lpk – library for executing scripts;

2. fast-report-N\Source\frN_lazarus.lpk (where n is the current version of FastReport) – package with all necessary components;

3. In any order:

- fast-report-N\Source\ExportPack\frxeN_lazarus.lpk – package with exports;
- fast-report-N\Source\lazchart\frxchartlazarus.lpk – packge for
- fast-report-N\Source\lazdbf\frxlazdbf.lpk – package for working with BDF databases;
- fast-report-N\Source\sqlite\frxlazsqlite.lpk – package for working with SqLite batabases.

Before version 2.0.0 a compile and/or install bug was very common, at the time of this writing the latest version is 2.0.6 and this bug in Lazarus has still not been completely removed, but it is much less likely to happen.

If you have 1 of the packages that won't compile/install you will have to go down and recompile/reinstall the package dependencies.

Installing FastReport packages in Lazarus for Linux / Windows

To do this, double click on it and recompile and then reinstall.

Once all packages have been successfully installed click Project -> Open Project and open fast-report-N\LDemo\FRDemo.lpi project and try to run it, then click Design.

If you get this negative height error in Linux:

Installing FastReport packages in Lazarus for Linux / Windows

Then don't worry. The point is that we support both GTK and QT interfaces (but keep in mind that development is mostly done in GTK). So, in some (rather rare) GTK interfaces this bug can be found. Simply run the application without debugging or check the "Ignore this type of exceptions" box.

*Or change your graphical shell. For example, many of our team works under GTK shell KDE Plasma, which has no such error.

One last thing you should know, when creating your projects, is that our designer uses multi-threading, which is disabled by default in Linux Lazarus. In order to turn it on, open a file with extension ".lpr" in Project Inspector (Project -> Project Inspector) and write in the first item in uses unit cthreads.