Compiler expectations

You should better use the latest SVN trunk version of the FPC 2.7.1 / 3.1.1 compiler, and the corresponding Lazarus IDE.

If you want to use TDocVariant custom variant type, ensure that your revision includes the fix for bug, i.e. newer than revision 28995 from 2014-11-05T22:17:54. This bug has not been fixed in 2.6.4 branch.

We recommend using the fpcup tool, as published at
To compile the latest svn version of the trunk, just write:

fpcup.exe --fpcURL="trunk" --lazURL="trunk"

Then ensure you set the static SQlite3 .o files for Windows or Linux in the right folder, as stated about the Installation.

Creating the missing RTTI for interfaces

Sadly, we have to face some unresolved FPC compiler-level issue, which does not supply the needed interface RTTI - see

As a result, SOA, mock/stub and MVC features would not working directly.
We propose a workaround to compile such applications with FPC. You could use Delphi to generate one unit containing the needed information.

The mORMotWrappers.pas unit proposes a ComputeFPCInterfacesUnit() function, which could be used on Delphi to generate the RTTI unit for FPC, as such:

  • Ensure that the application will use all its needed interface: for instance, run all your regression tests, and/or use all its SOA/MVC features if you are not confident about your test coverage;
  • Just before the application exists, add a call to ComputeFPCInterfacesUnit() with the proper folders, e.g. at the very end of your .dpr code.

For instance, here is how TestSQL3.dpr has been modified:

program TestSQL3;

If you define the COMPUTEFPCINTERFACES conditional, the TestSQL3FPCInterfaces.pas unit will be generated.
You can take a look at the committed version of this generated file.

Of course, for your own application, you may use absolute path names: here we used relative naming, via ..\, so that it would work on any development folder configuration.

Then, add it to any of your uses clause, as such:

  TestSQL3FPCInterfaces, // will register RTTI for interfaces under FPC

This unit will do nothing when compiled under Delphi: it will register the RTTI only when compiled with FPC.
The rest of your code would be untouched, and could be shared between Delphi and FPC.

If you do not modify the interface methods definition, this generation step could be safely bypassed.

We hope that in a close future, the FPC team would fix the issue, but the ticket seems pretty inactive since its creation.

Writing your project for FPC

If you want your application to compile with FPC, some little patterns should be followed.

In all your source code file, the easiest is to including the following mORMot file, which will define all compiler options and conditionals as expected:


Then in your .dpr file, you should write:

  {$ifdef Linux}
  // if you use threads
  // widestring manager for Linux if needed !!
  // could also be put in another unit ... but doc states: as early as possible
  cwstring, // optional

For instance a minimal FPC project to run the regression tests may be:

program LinuxSynTestFPCLinuxi386;

uses {$ifdef Linux} cthreads, cwstring, {$endif} mORMotSelfTests;
begin SQLite3ConsoleTests; end.

In your user code, ensure you do not directly link to the Windows unit, but rely on the cross-platform classes and functions as defined in SysUtils.pas, Classes.pas and SynCommons.pas.
You could find in SynFPCTypInfo.pas and SynFPCLinux.pas some low-level functions dedicated to FPC and Linux compilation, to be used with legacy units - your new code should better rely on higher level functions and classes.

If you rely on mORMot classes and types, e.g. use RawUTF8 for all your string process in the business logic, and do not use Delphi-specific features (like generics, or new syntax sugar), it would be very easy to let your application compile with FPC.

In practice, we use Delphi as our main IDE, then switch to Lazarus under a small integrated Linux VirtualBox, running a low resource XFCE desktop. We defined the Windows folder containing the source as a VirtualBox shared folder, so that we are able to compile, debug and test the Linux version of any executable in native Linux, on the same computer, from the very same sources. We found out that Lazarus debugging was pretty smooth on Linux - GDB is smoother on Linux than Windows, by the way. Then switching from Delphi/Windows to Lazarus/Linux is direct and natural, especially when the VirtualBox "Integrated Desktop" feature is enabled.

Linux installation tips

Here are a few informal notes about getting running a FPC/Lazarus virtual machine running XUbuntu, on a Windows host.
They are published as a general guideline, and we would not provide any reference procedure, nor support it.

  • Install the latest VirtualBox version from to Windows;
  • Download the latest .iso version published at or any other place - we use XFCE since it is a very lightweight desktop, perfect to run Lazarus, and we selected an Ubuntu LTS revision (14.04 at the time of this writing), which would be the same used on Internet servers;
  • Create a new virtual machine (VM) in VirtualBox, with 1 or 2 CPUs, more than 512 MB of RAM (we use 777 MB), and an automatic-growing disk storage, with a maximal size of 15 GB; ensure that the disk storage is marked as SSD if your real host storage is a SSD;
  • Let the CDROM storage point to the .iso you downloaded;
  • Start the VM and install Linux locally, as usual - you may select to download the updated packages during the installation, for safety;
  • When the system restarts, if it asks for software updates, accept and wait for the update installation to finish - it is a good idea to have the latest version of the kernel and libraries before installing the VirtualBox drivers;
  • Restart your VM when asked to;
  • Under a Ubuntu/Debian terminal, write the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install dkms
  • Restart the VM, then select "Insert Guest Additions CD image" from the VM "Devices" menu: a virtual CD would be mounted on your system and appear on your desktop;
  • Run the following command, according to your current user name and VirtualBox version:
 sudo sh /media/...user.../VBOXADDITIONS_..../
  • Restart the VM, then add a permanent shared folder in the VM configuration, named Lib, and pointing to your local mORMot installation (e.g. d:\dev\lib;
  • Create a void folder, e.g. in your home:
 mkdir lib
  • Create a launcher for the following command, to mount the shared folder as expected:
 sudo mount -t vboxsf lib /home/...user.../lib
sudo apt-get install build-essential mingw32-binutils subversion libgtk2.0-dev
sudo ln -s /usr/bin/i586-mingw32msvc-windres /usr/bin/windres
./fpcup_linux_x86 --fpcURL="trunk" --lazURL="trunk"
  • Now wait for all source to be retrieved by SVN, then the whole build to take places;
  • If you have issues during SVN retrieval, go the development/fpc folder, then run the following before trying again the fpcup_linux_x86 command:
svn cleanup
svn update
  • On success, you can create a launcher pointing to development/lazarus/startlazarus.

If you followed the above steps, you should now have at least a Lazarus IDE v1.3 and the corresponding FPC 3.1.1 compiler. It is amazing seeing the whole compiler + IDE being compiled from the official sources, for free, and in a few minutes.

In fact, this article has been extracted from our official documentation, which should be checked for its latest version!

Feedback is welcome on our forum, as usual!