Lazarus IDE Tutorial: Complete Beginner’s Guide

With over 7 million downloads, Lazarus IDE has proven itself as more than just a niche project. It continues to attract developers because it offers a fast, stable, and cost-free alternative to commercial IDEs, without sacrificing power or flexibility.

Beyond being free, Lazarus offers something developers rarely get: one codebase that compiles into native applications for Windows, macOS, and Linux. That combination of portability and database-ready components makes it a practical tool for building everything from business software to educational applications.

In this guide, you’ll learn how to install Lazarus, build a first GUI, connect it to a database, and test it across platforms. By the end, you’ll see exactly where Lazarus adds value, and how to put it to work in your own projects.

What is Lazarus IDE?

Lazarus IDE is a free, open-source development environment for the Pascal programming language. It gives developers both a powerful code editor and a visual design surface for building applications. Unlike many lightweight editors, Lazarus is a complete IDE that supports everything from designing graphical user interfaces (GUIs) to debugging, testing, and deploying applications.

The project began in the late 1990s with a clear goal: to provide a Delphi-like environment that is accessible to everyone. By combining Delphi’s familiar workflow with the openness of community-driven development, Lazarus has grown into a stable tool widely used for cross-platform software projects today.

Overview of Lazarus IDE and Free Pascal

Lazarus follows the Rapid Application Development (RAD) model, allowing developers to drag and drop interface components, link them to code, and produce a working application quickly. Built on the Free Pascal Compiler (FPC), it ensures that projects can be compiled into fast, native executables.

Lazarus mirrors Delphi’s workflows and the use of Delphi components, but beyond this, it adds the advantages of being open-source with the ability to compile for multiple operating systems. Meaning, with a single codebase, developers can target Windows, macOS, Linux, and even embedded platforms, making Lazarus especially appealing for cross-platform projects.

Key features of Lazarus

Here’s what you can expect when working with Lazarus:

  • Visual Form Designer: Allows you to build GUIs with simple drag-and-drop.
  • Lazarus Component Library (LCL): Enables cross-platform apps with native UI.
  • Built-in Debugger: Lets you step through code and inspect variables.
  • Cross-Compilation: Provides one codebase for deployment across platforms.
  • Native Binaries: Delivers fast executables without external runtimes.

Together, these features make Lazarus both beginner-friendly and professional-grade.

Is Lazarus IDE safe to use?

Yes. Lazarus IDE is both safe and reliable, with more than two decades of community-backed development behind it. Its safety comes from several factors, including:

  • Open-source transparency

Licensed under GPL and LGPL, Lazarus contains no ads, telemetry, or vendor lock-in. The code is publicly reviewed, so what you install is fully transparent.

  • Proven maturity

In active development since the late 1990s, the Lazarus software has earned a reputation for stability through consistent updates and long-term support.

  • Native executables

Applications compile into fast, standalone binaries, avoiding the hidden risks of external runtimes or bundled software.

  • Cross-platform resilience

Lazarus runs consistently on Windows, macOS, Linux, and embedded systems, proving its reliability across environments.

  • Community-driven support

A global network of professionals, educators, and hobbyists contribute code, documentation, and forums, ensuring issues are quickly resolved.

In short, the Lazarus software IDE is a safe choice for both beginners and professionals. It is transparent, stable, and backed by a strong developer community.

How to install Lazarus IDE on your OS

The installation process is slightly different across platforms, but the order is always the same: download the packages, install the Free Pascal Compiler (FPC) and sources, then configure paths if needed.

Downloading the Lazarus installer

Getting Lazarus on your system starts with the right installer for your operating system. Here’s where to download it and what’s included:

  • Windows: Download the combined Lazarus + FPC installer (.exe) from the official Lazarus download page. It bundles everything in one setup.
  • macOS: Download three separate packages: the Free Pascal Compiler (.dmg), which provides the core compiler used to build applications; the FPC Sources (.dmg), required for the Lazarus IDE to function correctly; and finally the Lazarus IDE (.pkg), which you install after setting up the compiler and sources.
  • Linux: Use your distribution’s package manager where possible.
sudo apt update
sudo apt install fpc fpc-source lazarus 

On Fedora, use dnf, and on openSUSE, zypper. Alternatively, download the .deb or .rpm files directly.

Installing Free Pascal Compiler (FPC)

The Free Pascal Compiler is the backbone of Lazarus. Installation varies by platform, so follow the correct order for your system:

  • Windows: The installer sets up both Lazarus and FPC automatically.
  • macOS: Install in this order: FPC > FPC Sources > Lazarus IDE. If Gatekeeper blocks the package, use Control + click > Open to proceed.
  • Linux: Installing with the package manager pulls in both FPC and the sources alongside Lazarus. If compiling from source, always install FPC first.

Environment configuration and paths

Once installed, Lazarus and FPC need to be properly recognized by your system. Check the following path settings per platform:

  • Windows: Path variables are configured automatically. If Lazarus reports “FPC not found,” add the Lazarus and FPC bin directories to your PATH manually.
  • macOS: Installed binaries live under /usr/local. Ensure /usr/local/bin is in your PATH if you plan to compile from the terminal.
  • Linux: With package installs, PATH is handled for you. If built from source, add the Lazarus and FPC bin directories to your shell configuration.

Verifying the installation

Open Lazarus from your Start Menu (Windows), Applications folder (macOS), or terminal (lazarus) on Linux. On first launch, Lazarus checks for the compiler, debugger, and FPC sources. If all indicators show green, your IDE is ready. On macOS, you may need to configure LLDB or GDB in Preferences > Debugger before running projects.

Getting started: create your first Lazarus project

Once Lazarus is installed, the best way to learn is by building a simple GUI application. The process involves creating a new project, designing the interface, writing some Pascal code, and running the program. Here’s how to do it step by step.

Starting a new GUI application

  1. Open Lazarus and go to File > New > Application.
  2. A blank form will appear, this is your program’s main window. Lazarus also creates the project structure, including:
File Purpose
unit1.pas Your Pascal source code
unit1.lfm Form layout definition
project1.lpi Project information/settings
project1.lpr Main program file (entry point)
  1. Save the project with a clear name (e.g., FirstApp) and choose a directory.

At this stage, you already have a working skeleton project.

Using form designer and components

The Form Designer lets you build the interface visually. On the right, the Component Palette provides UI elements such as buttons, labels, and text boxes.

  1. Drag a TButton onto the form.
  2. Add a TLabel and a TEdit to display and enter text.
  3. Use the Object Inspector to change properties like Caption (button text) and Name (component identifier).

This drag-and-drop approach saves time compared to hand-coding layouts.

Writing simple Pascal code for events

Now let’s give the button some behavior. Do the following:

  1. Double-click the button in the Form Designer (Lazarus opens unit1.pas at the Button1Click procedure, this is the OnClick event handler).
  2. Add code inside the procedure.

Here’s an example, to display a message.

procedure TForm1.Button1Click(Sender: TObject); 
 begin 
ShowMessage('Hello, Lazarus!'); 
 end;

This code shows a popup message when you click the button.

Another example, to calculate the sum of two numbers typed into Edit1 and Edit2.

procedure TForm1.Button1Click(Sender: TObject); 
 var 
a, b, sum: Integer; 
 begin 
if (Edit1.Text <> '') and (Edit2.Text <> '') then 
 begin 
a := StrToInt(Edit1.Text); 
 b := StrToInt(Edit2.Text);
sum := a + b; 
 Label1.Caption := 'Result: ' + IntToStr(sum); 
end 
 else 
ShowMessage('Please enter numbers in both fields.'); 
 end;

This code checks both fields, adds the numbers, and updates the label with the result.

Note
Always validate input before using StrToInt. An empty or invalid value will cause an error if not handled.

Building and running the application

Once you’ve added code, it’s time to see your project in action. Follow these steps to build, run, and test your application:

  1. Save your project (Ctrl+S).
  2. Click the green Run button (or press F9). Lazarus will compile your code and open a new window with your form.
  3. Test the button to see your code in action.

Troubleshooting tips

Error message How to fix
Identifier not found Check that you’re using the correct component names.
FPC not found Ensure Lazarus knows where your Free Pascal Compiler is installed; configure paths if prompted on first run.
Runtime errors with numbers Validate input before converting; make sure text boxes are not empty and contain valid integers.

By following these steps, you’ve built your first Lazarus GUI app, a simple but complete workflow from design to execution. The next logical step is to connect it to a database and turn it into something more practical.

Lazarus database tutorial: Building a CRUD app

With Lazarus, you can build a database-driven desktop app without relying on third-party tools. The IDE ships with SQLdb, a framework of components that handle database connectivity, transactions, and queries. In this part of the Lazarus tutorial, we’ll walk through connecting to a database, displaying data, and performing full CRUD operations.

Supported databases in Lazarus

Lazarus supports a wide range of relational databases. The table below shows the commonly used connectors, their targets, and key notes for configuration.

Connector type Database target Notes
TSQLConnector Generic (any DB) Set ConnectorType (e.g., MySQL, PostgreSQL, SQLite3)
TPQConnection PostgreSQL Easier setup than generic connector
TSQLite3Connection SQLite Point DatabaseName to the .sqlite file
TMySQL55Connection MySQL / MariaDB Requires MySQL client library installed
TIBConnection Firebird / InterBase Needs Firebird client
TOracleConnection Oracle Requires Oracle client libraries

Setting up the database connection

To connect Lazarus to your database:

  1. Drop these components from the SQLdb tab: TSQLConnector, TSQLTransaction, TSQLQuery.
  2. Wire them together as shown in the table below.
Component Property Points to
TSQLConnector Transaction Your TSQLTransaction
TSQLTransaction Database Your TSQLConnector
TSQLQuery Database/Transaction Same connection + transaction
  1. Configure the connection:
    • Set ConnectorType (MySQL, PostgreSQL, SQLite3, etc.).
    • Provide host, database name (or file path for SQLite), user, and password.
    • Toggle Connected := True to test.
SQLConnector1.ConnectorType := 'PostgreSQL'; 
SQLConnector1.HostName := 'localhost'; 
SQLConnector1.DatabaseName := 'sampledb';   
SQLConnector1.UserName := 'user'; 
SQLConnector1.Password := 'pass'; 
SQLConnector1.Connected := True;

Displaying and editing data

Lazarus can automatically display query results in data-aware controls. Here's how to do this:

  1. Add a TDataSource and TDBGrid to your form.
  2. Bind them as shown below:
Component Property Points to
TDataSource DataSet Your TSQLQuery
TDBGrid DataSource Your TDataSource
  1. Fetch rows with the following query:
SQLQuery1.SQL.Text := 'SELECT id, name, email FROM customers ORDER BY id'; 
SQLQuery1.Open;

The DBGrid now shows your table data. Optionally, add a TDBNavigator for record navigation.

Performing CRUD operations

CRUD in Lazarus follows a pattern: prepare SQL, assign parameters, execute, and commit the transaction. Below are code examples for each operation, showing how to implement them in practice.

Create (INSERT)

SQLQuery1.Close;
SQLQuery1.SQL.Text := 'INSERT INTO customers (name,email) VALUES (:n,:e)';
SQLQuery1.ParamByName('n').AsString := EditName.Text;
SQLQuery1.ParamByName('e').AsString := EditEmail.Text;
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;

Read (SELECT)

SQLQuery1.Close;
SQLQuery1.SQL.Text := 'SELECT * FROM customers WHERE id=:id';
SQLQuery1.ParamByName('id').AsInteger := StrToInt(EditId.Text);
SQLQuery1.Open;

Update

SQLQuery1.Close;
SQLQuery1.SQL.Text := 'UPDATE customers SET email=:e WHERE id=:id';
SQLQuery1.ParamByName('e').AsString := EditEmail.Text;
SQLQuery1.ParamByName('id').AsInteger := StrToInt(EditId.Text);
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;

Delete

SQLQuery1.Close;
SQLQuery1.SQL.Text := 'DELETE FROM customers WHERE id=:id';
SQLQuery1.ParamByName('id').AsInteger := StrToInt(EditId.Text);
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;

Refreshing the grid

SQLQuery1.Close;
SQLQuery1.SQL.Text := 'SELECT id, name, email FROM customers ORDER BY id';
SQLQuery1.Open;

Key takeaways

  • Commit each transaction after write operations.
  • Prefer DB-specific connectors to simplify setup.
  • Use data-aware controls (TDBGrid, TDBNavigator, TDBEdit) to speed up UI binding.
  • Follow the CRUD pattern in Lazarus: simple SQL, full control, clean UI integration.

After adding database functionality, the focus shifts to reliability. Debugging and testing ensure your Lazarus applications behave as expected across different environments.

Debugging and testing in Lazarus IDE

Debugging is where your code turns from guesswork into certainty. Lazarus includes a built-in debugger (based on GDB or LLDB, depending on your platform) along with stack traces, logging, and cross-platform testing support.

In this section, you’ll see how to use breakpoints, watches, call stacks, and test strategies to find and fix issues effectively.

Using breakpoints and watches

Breakpoints let you stop execution at a chosen line; watches let you track variable values as the program runs. The table below shows how each works and how to use it.

Feature Purpose How to use
Breakpoints Pause program at a specific line Click margin or press F5; right-click to enable conditions
Watches Monitor variable values during runtime Right-click variable > Add Watch; updates live as you step
Tip
Make sure Project > Project Options > Debugging > Generate Debug Info is enabled, otherwise breakpoints won’t trigger. If they still fail, run Clean and Build to remove stale compiled units.

Inspecting stack traces and logs

When exceptions occur, Lazarus generates a call stack that shows the sequence of procedure calls leading to the error. Logging adds another layer by letting you confirm assumptions without stepping through every line of code. The table below shows the main tools you can use for stack inspection and logging.

Tool What it shows When to use
Call Stack Window Sequence of function calls before error Trace how execution reached the failure point
Stop on Exception Pauses app when exceptions are raised Identify the exact line triggering errors
DebugLn / writeln Logs variable values or checkpoints Verify program flow between breakpoints
Note
If stack traces appear cryptic, recompile with debugging info (-g in compiler options) to see source-level details.

Cross-platform testing tips

Because Lazarus is cross-platform, testing on each OS is non-negotiable. Subtle differences in layout, fonts, and permissions often only show up at runtime. The table below lists what to check on each system.

Platform Key checks
Windows Ensure executables run standalone; confirm no missing DLLs
macOS Use LLDB; handle Gatekeeper prompts; verify layout scaling on Retina displays
Linux Test across GNOME/KDE; confirm widget sizing and fonts; check stricter file permissions
Tip
Lazarus supports cross-compiling, but always run your app natively on the target OS to catch environment-specific issues.

Debugging shortcuts

Speed matters when you’re chasing bugs. Below are the most useful Lazarus debugging shortcuts.

Shortcut Action
F9 Run / Continue
F5 Toggle breakpoint
F7 Step Into
F8 Step Over
Shift+F8 Step Out

Key takeaways

  • Always enable debugging info before relying on breakpoints.
  • Use a mix of breakpoints, watches, and logs for clarity.
  • Inspect call stacks carefully to find not just where, but why code failed.
  • Test across platforms to ensure your app behaves consistently.

Once you know how to debug and test effectively, the next challenge is efficiency.

Lazarus IDE productivity tips and shortcuts

Lazarus provides a number of features that save time, reduce errors, and speed up development. By adjusting key settings, using built-in shortcuts, and leveraging code templates, you can work more efficiently inside the IDE.

Useful Lazarus IDE settings

Here are a few settings that can make Lazarus much smoother for daily use.

Setting Why it helps Where to find it
Code formatting Keeps code consistent and readable Tools > Options > Editor > Source Formatter
Autosave Prevents data loss if the IDE or OS crashes Tools > Options > Environment > Autosave
Version control integration Lets you manage Git/SVN directly from Lazarus Tools > Options > Environment > Version Control
Tip
Set autosave to at least every 5 minutes and on compile to avoid losing work during long debugging sessions.

Keyboard shortcuts for faster development

Below are the essential keyboard shortcuts that can dramatically improve speed.

Shortcut Action
Ctrl+S Save current file
F9 Compile & Run
Shift+F9 Compile only
Ctrl+Shift+F Format source code
Ctrl+Q Comment/Uncomment selection
Ctrl+Shift+Arrow Navigate between open tabs
Tip
Customize shortcuts under Tools > Options > Editor > Key Mappings if you’re coming from another IDE like Delphi or Visual Studio.

Using code templates and code tools

The table shows templates and code tools that help generate boilerplate code automatically.

Feature Purpose Example
Code templates Insert common patterns quickly Type fori + Tab → generates a for loop
Code completion Suggests units, methods, properties as you type Start typing a class name → IDE completes it
Code tools Create event handlers or database bindings automatically Double-clicking a button adds OnClick event code
Tip
Explore built-in templates (Tools > Code Tools > Code Templates). You can add your own snippets for recurring patterns, like DB queries or error handlers.

Key takeaways

  • Turn on autosave to protect your work.
  • Use F9 (Run) and Shift+F9 (Compile only) to speed up testing.
  • Rely on code templates (fori, tryf, etc.) for boilerplate loops and blocks.
  • Keep code formatted with Ctrl+Shift+F for consistency.
  • Integrate version control early so you never lose history.

Now that you’ve seen how to work faster inside Lazarus, let’s explore how to work smarter with your databases.

Integrating Devart DAC with Lazarus

SQLdb is fine for small projects, but it quickly shows its limits when you need high-performance queries, advanced database features, or multi-database portability. This is where Devart Data Access Components (DAC) become the clear choice.

What DAC brings to Lazarus

DAC integrates directly into the Lazarus IDE. Once installed, the components appear in the Component Palette beside your standard SQLdb tools. From there, you work the same way you’re used to: drop a connection, drop a query, wire them together, but with far greater capability.

Supported databases

DAC doesn’t lock you into a single backend. Out of the box, it supports:

  • Oracle - via ODAC
  • MySQL / MariaDB - via MyDAC
  • PostgreSQL - via PgDAC
  • SQLite - via LiteDAC
  • Microsoft SQL Server via SDAC
  • Firebird / InterBase via IBDAC

For projects that must support multiple database systems, Devart provides UniDAC, which offers a unified API for working with different database servers using the same codebase.

In addition to the databases listed above, UniDAC allows connecting to other systems such as:

  • DB2
  • Microsoft Access
  • NexusDB
  • Advantage Database Server
  • Sybase ASE
  • ODBC data sources
  • file-based databases (DBF, Excel, etc.)

This makes Devart DAC a flexible solution for Lazarus applications that need to scale from a single database to multi-database or cross-platform environments without rewriting the data access layer.

This also makes it a strong fit for teams that need Delphi PostgreSQL connectivity to scale applications across multiple platforms.

Why experienced developers choose Devart DAC

SQLdb is solid for basic projects, but scaling up often exposes gaps. The table below shows how DAC components extend SQLdb in the areas that matter most:

SQLdb constraint How DAC extends it
Each database requires its own connector. Unified access layer – one API for multiple databases, reducing code rewrites.
Query performance slows with complex or high-volume operations. Optimized drivers – tuned for faster execution and lower overhead.
Advanced features such as stored procedures and custom datatypes are only partially supported. Broader coverage – clean support for stored procedures, direct connections, and advanced datatypes
Behavior can vary when migrating projects across operating systems. Cross-platform consistency – components behave predictably on Windows, macOS, and Linux.

With DAC, you don’t fight your tools, you focus on application logic, knowing the data layer will scale.

How to get started in Lazarus

Integrating Devart DAC into Lazarus is a straightforward process: you install the component package, rebuild the IDE, and then the new database components appear on your palette, ready to use. The steps come directly from Devart’s official documentation and apply across UniDAC, MyDAC, LiteDAC, and other DAC families. The following steps show how to add DAC to Lazarus and create your first working connection.

Step 1: Install the package

  • Open Lazarus and navigate to Package > Package File (.lpk).
  • Choose the DAC package for your edition.
DAC family Full version package Trial version package
UniDAC %UniDAC%\Source\Lazarus1\dclunidac10.lpk %UniDAC%\Packages\dclunidac10.lpk
MyDAC %MyDAC%\Source\Lazarus1\dclmydac10.lpk %MyDAC%\Packages\dclmydac10.lpk
LiteDAC %LiteDAC%\Source\Lazarus1\dcllitedac10.lpk %LiteDAC%\Packages\dcllitedac10.lpk
  • Click Install. Lazarus will rebuild itself and add DAC components to the Component Palette. (In trial editions, compiling fails because sources are not included).

Step 2: Add components to a form

After Lazarus restarts, open a new form and drag DAC components onto it:

  • TUniConnection: configure this component with your database credentials; it establishes the active connection.
  • TUniQuery: attach this to the connection and use it to run SQL statements or parameterized queries.

Set your connection properties, drop in a query, and you’re ready to run commands against your database.

Step 3: Verify installation

At this stage, the package should be fully integrated into Lazarus. Before moving on, confirm the following:

  • Always select Install, not Compile, for trial packages.
  • The installation procedure is the same across all DAC families.
  • Check Devart’s release notes to ensure your Lazarus version is supported.

Download Devart DAC and integrate it into Lazarus today. If you’re serious about database applications, DAC is the professional-grade option.

Conclusion

Lazarus proves that open-source tools can deliver professional results. It gives you a visual IDE, a stable compiler, and cross-platform reach without the licensing costs of commercial environments. You can design forms visually, wire up events in Pascal, and connect to databases in minutes.

For most developers, the real attraction is freedom: one codebase, deployable to Windows, macOS, and Linux. Add to that a strong community and a mature feature set, and Lazarus becomes more than just a beginner’s IDE, it’s a production-ready environment.

If you’re ready to go beyond SQLdb and build faster, more flexible data-driven applications, the next step is clear. Download Devart DAC and try it with Lazarus IDE today.

Frequently asked questions

Is Lazarus IDE safe for production-level database application development?

Yes. Lazarus is open-source, stable, and actively maintained by its community. Many developers use it in production, especially when paired with components like Devart DAC for professional-grade database connectivity.

What debugging tools and breakpoints are available in Lazarus IDE?

Lazarus includes a built-in debugger based on GDB or LLDB. You can set breakpoints, add watches to track variables, step through code, and inspect the call stack. Logging functions like DebugLn also make it easy to trace program flow.

Can Lazarus IDE be used to compile cross-platform applications—on Linux, Windows, macOS?

Yes. Lazarus and Free Pascal let you maintain a single codebase and compile it into native executables for Windows, macOS, and Linux, making it especially practical for cross-platform development.

Which Devart DAC edition (e.g., UniDAC, SDAC, PgDAC) is best suited for Lazarus users on Linux or macOS?

UniDAC is the most versatile option. It provides a unified API across multiple databases and runs consistently on Linux and macOS, so you don’t have to manage database-specific packages.

See how to install UniDAC on Windows, Linux, and macOS and connect to a database

UniDAC is a specifically designed Delphi Data Access Connector library that allows the development of multi-platform applications in various environments via providing direct access to various Delphi, Lazarus, and C++ Builder databases in 32-bit and 64-bit platforms of Windows, Linux, macOS, iOS, and Android.

Universal Data Access Components

Native connectivity to various databases and clouds from Delphi