Photo by Magda Ehlers from Pexels

Getting started with mORMot and Lazarus/Free Pascal

Stephan Bester
4 min readDec 27, 2020


This article describes steps for setting up Lazarus with mORMot so that you can start using this wonderful, diverse framework in your Free Pascal projects.

You can find the Delphi version here.

Getting Lazarus

Find and download the binaries for your preferred installation of Lazarus here on the Free Pascal wiki. If you’re running Windows, you’ll probably find what you need on the SourceForge page.

Welcome to the Lazarus Setup Wizard

For more advanced installations, e.g. if you want to compile the latest version from the source code, see this page on the wiki.

Getting mORMot

Next, acquire the mORMot library. At the time of writing, Synopse claims on their download page that the “unstable” 1.18 trunk version is more stable than the latest “stable” 1.17 version. Therefore, it makes sense to download the latest build.

A warning from mORMot

The simplest way to do this is to visit the FreePascal/Lazarus installation section of their online documentation. Following the steps there, download the nightly build using the link provided and extract this wherever you keep your third party libraries.

Once again according to the Synopse download page, this package does not include the requisite SQLite3 object files. You need to download these separately using the link provided. This archive contains a directory named static which has subdirectories for various CPU and OS combinations. These files must be copied into the static directory under wherever you extracted the mORMot library, e.g.


Configuring your project

Now, your FreePascal project must be configured to use mORMot.

From the “Project” menu, open the “Project Options” dialogue. In the tree on the left, navigate to “Compiler Options” and select “Paths”.

Paths in Project Options

Assuming that you extracted the mORMot library into D:\Dev\mORMot, add the following paths to “Other unit files (-Fu):


Add these paths to “Include files (-Fi)”:


For all of these, Lazarus should automatically transform the paths into relative paths. Finally, the mORMot documentation also advises to add the following path to “Libraries (-Fl)”:


Note that this is the path to the contents of the sqlite3fpc.7z archive you extracted earlier. Upon closing the options dialogue, you might get a warning like this:

Nonexistent directory warning

If this happens, it could mean that you haven’t extracted the contents of the SQLite3 objects files into the right path (see the previous section).

Testing your configuration

The easiest way to test that Lazarus picks up mORMot is to open up one of the sample projects. Load the following project from the extracted mORMot source:

SQLite3\Samples\01 - In Memory ORM\Project01.lpr

Confirm that the Project Options are set up as described above and run it. If everything is correctly configured, the project will compile successfully and you will be presented with the following somewhat minimalistic UI:

Sample 01 — In Memory ORM

To be thorough, enter a name and a message and click “Add the message”. This adds a record to an in-memory SQLite3 database. To search the database for your record, enter the same name again and click “Find a previous message”. You should see the same message again. Et voila!

Further reading

The mORMot documentation includes a section, Writing your projects for FPC, where Synopse makes certain recommendations for getting your applications to compile with FreePascal.

You may also be interested in one of my other articles on the framework. Although these are Delphi-focused, they should still be useful to Free Pascal developers:

Used for this article:

  • Lazarus 2.0.10 with FreePascal 3.2.0 (win64)
  • mORMot 1.18
  • Windows 10 Pro



Stephan Bester

Software developer walking the edge between legacy systems and modern technology. I also make music: