Adopt a mORMot
This chapter covers the licensing terms of the mORMot 2 framework, its source code availability, and complete installation instructions for both Delphi and Free Pascal/Lazarus development environments. Understanding how to properly set up your development environment is essential for working effectively with mORMot 2.
The framework source code is licensed under a disjunctive three-license giving the user the choice of one of the three following sets of free software/open source licensing terms:
As a special exception of the LGPL, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
This allows the use of the framework code in a wide variety of software projects, while still maintaining intellectual rights on library code.
In short:
In all cases, any modification made to this source code should be published by any mean (e.g. a download link), even in case of MPL. If you need any additional feature, use the forums and we may introduce a patch to the main framework trunk.
You do not have to pay any fee for using our MPL/GPL/LGPL libraries.
But please do not forget to put somewhere in your credit window or documentation, a link to https://synopse.info if you use any of the units published under this tri-license.
For instance, if you select the MPL license, here are the requirements:
http://YourSoftwareCompany.com/MPL), with a description of applied modifications, and no removal of the original license header in source code;Note that this documentation is under GPL 3.0 license only, as stated in this document front page.
If you want to include part of the framework source code in your own open-source project, you may publish it with a comment similar to this one:
{
Sample based on official mORMot 2 sample
Synopse mORMot 2 framework. Copyright (C) 2025 Arnaud Bouchez
Synopse Informatique - https://synopse.info
Original tri-license: MPL 1.1/GPL 2.0/LGPL 2.1
}
You need to ensure that your Open Source project licensing is compatible with our Licensing Terms, and, if possible, notify us that you use our code.
There are countries that restrict the use, import, export of cryptographic software. Before keeping, using, or distributing the software, make sure that you comply with these restrictions. If (for any reason) you are unable to do so, you are not allowed to download, use, or distribute the software.
If you are residing in a country that allows software patents you must verify that no part of the software is covered by a patent in your country. If (for any reason) you are unable to do so, you are not allowed to use or distribute the software.
Even though our libraries are Open Source with permissive licenses, some users want to obtain a license anyway. For instance, you may want to hold a tangible legal document as evidence that you have the legal right to use and distribute your software containing our library code, or, more likely, your legal department tells you that you have to purchase a license.
If you feel like you really have to purchase a license for our libraries, Synopse, the company that employs the architect and principal developer of the library, will sell you one. Please contact us directly for a contract proposal.
As a true Open Source project, all source code of the framework is available. The primary location for mORMot 2 source code is:
GitHub Repository: https://github.com/synopse/mORMot2
The source has been commented following the scheme used by documentation tools. All interface definitions of the units have special comments which provide inline documentation.
There are two primary methods to obtain the mORMot 2 source code:
Cloning the Git repository is the preferred method, as it allows you to easily update to the latest version:
git clone https://github.com/synopse/mORMot2.git
For example, clone into c:\github\mORMot2 on Windows or ~/github/mORMot2 on Linux/macOS.
For a specific stable version (e.g., for use in a build script):
1. Go to https://github.com/synopse/mORMot2/releases
2. Download the Source code (zip) for your desired release
3. Extract it to your chosen location (e.g., d:\mormot2)
After obtaining the source code, you need to download the static libraries for SQLite3 and other compiled C code:
Download Options:
static sub-folder of your mORMot 2 installation.
For example, if you cloned to c:\github\mORMot2, the static files should be in c:\github\mORMot2\static\.
For safety, the SHA-256 checksums of the current version of the downloaded binary files are available in the static/dev.sha256 file.
Important: Always keep the static binaries in sync with the framework source code. Version mismatches can cause unexpected errors.
The static files are typically updated to match SQLite3 releases, sometimes with a short delay to ensure stability after major SQLite3 releases.
The mORMot 2 repository is organized into the following main folders:
| Folder | Description |
|---|---|
src/ |
Main source code folder containing the framework units |
packages/ |
IDE packages and tools for development environment setup |
static/ |
Pre-compiled binary .o/.obj files for static linking |
test/ |
Regression tests for all framework features |
res/ |
Resources used within src/, including static third-party binaries source |
doc/ |
Framework documentation |
ex/ |
Example projects and samples |
The src/ folder contains the framework source code organized into logical layers:
| Sub-folder | Description | Key Units |
|---|---|---|
core/ |
Core utilities: RTTI, JSON, text, logging, threads | mormot.core.base.pas, mormot.core.json.pas, mormot.core.log.pas |
lib/ |
Raw API definitions for external libraries | mormot.lib.openssl11.pas, mormot.lib.curl.pas |
crypt/ |
Cryptographic primitives and secure protocols | mormot.crypt.core.pas, mormot.crypt.jwt.pas, mormot.crypt.openssl.pas |
net/ |
Network layer: HTTP, WebSockets, async servers | mormot.net.http.pas, mormot.net.server.pas, mormot.net.ws.pas |
db/ |
Database access: SynDB, SQLite3, SQL/NoSQL | mormot.db.core.pas, mormot.db.sql.pas, mormot.db.nosql.mongodb.pas |
orm/ |
Object-Relational Mapping | mormot.orm.core.pas, mormot.orm.sql.pas |
rest/ |
REST client and server | mormot.rest.core.pas, mormot.rest.server.pas, mormot.rest.http.server.pas |
soa/ |
Service-Oriented Architecture (interfaces) | mormot.soa.core.pas, mormot.soa.server.pas |
app/ |
Application layer: daemon, console helpers | mormot.app.daemon.pas, mormot.app.console.pas |
script/ |
Scripting engine support (QuickJS) | mormot.script.quickjs.pas |
ui/ |
User interface components (VCL/LCL) | mormot.ui.controls.pas |
ddd/ |
Domain-Driven Design support | DDD infrastructure and patterns |
tools/ |
Command-line tools source code | ECC tool, etc. |
misc/ |
Miscellaneous utilities | Various helper units |
The src/ folder contains important include files:
| File | Description |
|---|---|
mormot.defines.inc |
Global compiler conditionals and settings |
mormot.uses.inc |
Common uses clause for console applications |
mormot.commit.inc |
Current commit hash (updated automatically) |
The static/ folder contains pre-compiled binaries organized by target platform:
For FPC (cross-platform):
static/
├── i386-win32/ # Windows 32-bit
├── x86_64-win64/ # Windows 64-bit
├── i386-linux/ # Linux 32-bit
├── x86_64-linux/ # Linux 64-bit
├── aarch64-linux/ # Linux ARM64
├── arm-linux/ # Linux ARM32
├── i386-darwin/ # macOS 32-bit (legacy)
├── x86_64-darwin/ # macOS 64-bit Intel
├── aarch64-darwin/ # macOS ARM64 (Apple Silicon)
├── x86_64-freebsd/ # FreeBSD 64-bit
└── x86_64-openbsd/ # OpenBSD 64-bit
For Delphi:
static/
└── delphi/ # Win32 .obj and Win64 .o files
The framework source code:
Note: FPC 3.2.2 has a regression with variant late binding. Use the FPC 3.2.3 fixes branch instead.
Server-Side (Full Framework):
| Platform | FPC | Delphi |
|---|---|---|
| Windows 32-bit | ✓ | ✓ |
| Windows 64-bit | ✓ | ✓ (XE2+) |
| Linux x86_64 | ✓ | - |
| Linux i386 | ✓ | - |
| Linux ARM64 | ✓ | - |
| Linux ARM32 | ✓ | - |
| macOS Intel | ✓ | - |
| macOS Apple Silicon | ✓ | - |
| FreeBSD | ✓ | - |
| OpenBSD | ✓ | - |
The static .o/.obj files are not mandatory to compile the framework. There is always a "pure Pascal" fallback code available for:
Follow these steps to set up mORMot 2 for Delphi:
Step 1: Get the Source Code
Clone the repository or download a release:
cd c:\github
git clone https://github.com/synopse/mORMot2.git
Step 2: Download Static Libraries
Download and extract mormot2static.7z from https://synopse.info/files/mormot2static.7z into c:\github\mORMot2\static\.
Step 3: Create Environment Variable
In Delphi IDE:
1. Go to Tools → Options → IDE → Environment Variables
2. Create a new User System Override variable:
- Name: mormot2
- Value: c:\github\mORMot2\src (or your chosen path)
Step 4: Configure Library Paths
In Delphi IDE: 1. Go to Tools → Options → Language → Delphi Options → Library 2. Add the following to the Library path for each target platform (Win32, Win64):
$(mormot2);$(mormot2)\core;$(mormot2)\lib;$(mormot2)\crypt;$(mormot2)\net;$(mormot2)\db;$(mormot2)\rest;$(mormot2)\orm;$(mormot2)\soa;$(mormot2)\app;$(mormot2)\script;$(mormot2)\ui;$(mormot2)\tools;$(mormot2)\misc
Step 5: Verify Installation
1. Open test/mormot2tests.dpr in the IDE
2. Compile and run the regression tests
3. All tests should pass on your machine
Here's a condensed version of the library path string to copy:
$(mormot2);$(mormot2)\core;$(mormot2)\lib;$(mormot2)\crypt;$(mormot2)\net;$(mormot2)\db;$(mormot2)\rest;$(mormot2)\orm;$(mormot2)\soa;$(mormot2)\app;$(mormot2)\script;$(mormot2)\ui;$(mormot2)\tools;$(mormot2)\misc
Unlike some frameworks, mORMot 2 does not require installing IDE packages for Delphi. Simply configure the library paths and you're ready to go.
The framework uses relative paths in its source code to include the expected .o/.obj files from the static\delphi sub-folder automatically.
After setup, compile and run the test project:
1. Open test/mormot2tests.dpr
2. Select your target platform (Win32 or Win64)
3. Build and run
4. Review the test results
The test suite covers all framework features and serves as both validation and usage examples.
You can use the FreePascal Compiler (FPC) to (cross-)compile mORMot 2 for the following platforms:
Windows:
The easiest way to set up mORMot 2 for Lazarus is to use the provided package:
Step 1: Get Source and Static Files
git clone https://github.com/synopse/mORMot2.git
cd mORMot2
# Download and extract mormot2static.tgz into the static/ folder
Step 2: Install the Package
1. Open Lazarus IDE
2. Go to Package → Open Package File (.lpk)
3. Navigate to packages/lazarus/mormot2.lpk
4. Click Compile (not Install - it's a runtime package)
For UI components, also compile packages/lazarus/mormot2ui.lpk.
Step 3: Configure Your Project
Add mormot2 package as a dependency to your Lazarus project:
1. Open your project
2. Go to Project → Project Inspector
3. Click Add → New Requirement
4. Select mormot2
For command-line compilation or when not using the package:
Project Options:
Add to Other unit files (-Fu):
/path/to/mORMot2/src;/path/to/mORMot2/src/core;/path/to/mORMot2/src/lib;/path/to/mORMot2/src/crypt;/path/to/mORMot2/src/net;/path/to/mORMot2/src/db;/path/to/mORMot2/src/rest;/path/to/mORMot2/src/orm;/path/to/mORMot2/src/soa;/path/to/mORMot2/src/app
Add to Include files (-Fi):
/path/to/mORMot2/src
Add to Libraries (-Fl):
/path/to/mORMot2/static/$(TargetCPU)-$(TargetOS)
The $(TargetCPU)-$(TargetOS) macro automatically selects the correct static library folder based on your compilation target.
We recommend using fpcupdeluxe to set up a stable FPC/Lazarus environment:
1. Download from https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases
2. Run the executable
3. Select FPC version 3.2 and Lazarus version matching your needs
4. Click "Install/update FPC+Laz"
Cross-Compilation:
fpcupdeluxe makes cross-compilation easy: 1. Go to the "Cross" tab 2. Select your target CPU and OS 3. Click "Install compiler" 4. Download cross-compiler binaries when prompted
This allows you to build Linux executables from Windows, or vice versa.
Recommended: FPC 3.2.3 (fixes-3_2 branch)
Known Issues:
Here's a minimal FPC project structure:
program MyMormotApp;
{$I mormot.defines.inc}
{$APPTYPE CONSOLE}
uses
{$I mormot.uses.inc} // Includes FPC-specific units for Linux
mormot.core.base,
mormot.core.text;
begin
writeln('Hello from mORMot 2!');
writeln('Current UTC: ', DateTimeToIso8601(NowUtc, true));
end.
The mormot.uses.inc file automatically includes the necessary units for FPC on various platforms (e.g., cthreads, cwstring on Linux).
In all your source code files, include the mORMot 2 defines file to set all compiler options and conditionals:
{$I mormot.defines.inc}
This include file defines essential conditionals like HASINLINE, OSWINDOWS, OSPOSIX, CPU architecture flags, and more.
To ensure your code compiles on both Delphi and FPC, and on multiple platforms:
1. Avoid Direct Windows Unit Usage: Don't directly reference the Windows unit in cross-platform code. Use mormot.core.os instead.
2. Use Framework Types: Rely on mORMot 2 types like RawUtf8 for string handling in business logic.
3. Conditional Compilation: When platform-specific code is needed:
{$ifdef OSWINDOWS}
// Windows-specific code
{$endif OSWINDOWS}
{$ifdef OSPOSIX}
// Linux/macOS/BSD code
{$endif OSPOSIX}
4. Use mormot.uses.inc: In your .dpr/.lpr files:
uses
{$I mormot.uses.inc} // Handles platform-specific units
mormot.core.base,
// ... your units
Key conditionals defined in mormot.defines.inc:
| Conditional | Description |
|---|---|
OSWINDOWS |
Compiling for Windows |
OSPOSIX |
Compiling for POSIX (Linux, macOS, BSD) |
OSLINUX |
Compiling for Linux specifically |
OSDARWIN |
Compiling for macOS |
CPU32 |
32-bit architecture |
CPU64 |
64-bit architecture |
CPUINTEL |
x86 or x86_64 architecture |
CPUARM |
ARM architecture |
FPC |
FreePascal Compiler |
ISDELPHI |
Delphi compiler |
HASINLINE |
Inline functions supported |
PUREMORMOT2 |
Use only mORMot 2 type names |
For cross-platform projects:
myproject/
├── src/
│ ├── myproject.core.pas # Business logic (cross-platform)
│ └── myproject.server.pas # Server components
├── bin/
│ ├── win32/ # Windows 32-bit output
│ ├── win64/ # Windows 64-bit output
│ └── linux64/ # Linux 64-bit output
├── test/
│ └── myproject.tests.dpr # Regression tests
├── myproject.server.dpr # Delphi project
├── myproject.server.lpr # Lazarus project
└── myproject.server.lpi # Lazarus project info
Deploying a mORMot 2 server on Linux is straightforward:
1. Cross-compile your application for x86_64-linux (or your target architecture)
2. Copy the executable to your Linux server
3. Run it directly - no runtime dependencies needed
The static linking of SQLite3 and other libraries means you don't need to install anything on the server.
Minimal Dependencies:
A typical mORMot 2 Linux executable only requires:
libpthread.so.0 # Threading (standard)
libdl.so.2 # Dynamic loading (standard)
libc.so.6 # C library (standard)
These are present on every Linux distribution.
mORMot 2 works well in Docker containers. A minimal Dockerfile:
FROM scratch
COPY myserver /
ENTRYPOINT ["/myserver"]
Since mORMot 2 executables are statically linked, you can even use a scratch (empty) base image.
For Windows service deployment, use mormot.app.daemon which provides cross-platform daemon/service functionality. The same code can run as:
mORMot 2 is a complete rewrite of the framework, addressing:
TOrm instead of TSQLRecord)1. Create a New Folder: Don't replace mORMot 1.18; install mORMot 2 in a separate location
2. Update Unit Names: All units have been renamed:
- SynCommons.pas → mormot.core..pas (split into multiple units)
- mORMot.pas → mormot.orm..pas + mormot.rest..pas
- SynDB.pas → mormot.db..pas
- See Chapter 3 for complete unit mapping
3. Update Type Names: In PUREMORMOT2 mode:
- TSQLRecord → TOrm
- TSQLRest → TRest
- TSQLModel → TOrmModel
4. Review Breaking Changes: - Delphi 5-6 and Kylix support removed - BigTable, LVCL, RTTI-UI deprecated - Some internal APIs changed
5. Consult Examples: The ex/ folder contains updated examples showing new patterns
You can maintain both mORMot 1.18 and mORMot 2 on the same system:
The ex/ folder contains many examples:
ex/ThirdPartyDemos/tbo/) provide particularly good step-by-step learning resources.
Contributions are welcome:
| Previous | Index | Next |
|---|---|---|
| Chapter 25: Testing and Logging | Index | - |