This extension supports compiling Lazarus projects using both lazbuild and fpc compilers with automatic fallback.
When building a Lazarus project (.lpi or .lpr files), the extension follows this priority:
- Primary: Use
lazbuildif available and preferred - Fallback: Use
fpccompiler with extracted build options
You can control whether to prefer lazbuild over fpc using the configuration:
{
"fpctoolkit.lazarus.preferLazbuild": true
}true(default): Trylazbuildfirst, fallback tofpcfalse: Always usefpccompiler
The extension automatically detects lazbuild in the following order:
- Check if
lazbuildis available in system PATH - Check common installation paths:
- Windows:
C:\lazarus\lazbuild.exe,C:\Program Files\Lazarus\lazbuild.exe - macOS:
/usr/local/bin/lazbuild,/Applications/Lazarus/lazbuild - Linux:
/usr/bin/lazbuild,/usr/local/bin/lazbuild
- Windows:
- Check
LAZARUSDIRenvironment variable orfpctoolkit.env.LAZARUSDIRsetting
When using lazbuild, the extension:
- Passes the correct build mode using
--build-mode=<mode> - Uses
--build-allfor rebuild operations - Adds
--quietflag to reduce output noise
When using fpc fallback, the extension:
- Extracts build options from the Lazarus project file
- Converts Lazarus-specific settings to FPC command-line options
- Maintains compatibility with existing FPC workflows
Using lazbuild provides several advantages:
- Native Lazarus Support: Handles Lazarus-specific build configurations automatically
- Build Mode Support: Properly processes different build modes defined in
.lpifiles - Dependency Management: Automatically handles package dependencies
- Optimized Compilation: Uses Lazarus's optimized build process
When lazbuild is available and preferred:
Using lazbuild compiler
lazbuild --build-mode=Release --quiet MyProject.lpi
When lazbuild is unavailable or not preferred:
Using fpc compiler
fpc MyProject.lpr -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -Fu./lib -FU./out
If lazbuild is not detected:
- Ensure Lazarus is properly installed
- Add Lazarus installation directory to your system PATH
- Set the
LAZARUSDIRenvironment variable - Configure
fpctoolkit.env.LAZARUSDIRin VS Code settings
The extension provides detailed error reporting for both compilers:
- lazbuild errors: Parsed from lazbuild output and displayed in Problems panel
- fpc errors: Standard FPC error parsing with line/column information
If lazbuild fails or is unavailable, the extension automatically falls back to fpc with:
- Extracted compiler options from the Lazarus project
- Converted build settings
- Standard FPC error reporting
The extension respects the following environment variables:
LAZARUSDIR: Path to Lazarus installation directoryPP: Path to FPC compiler (fallback)FPCDIR: Path to FPC source directory
--build-mode=<mode>: Specify build mode--build-all: Force rebuild all units--quiet: Reduce output verbosity
The extension automatically converts Lazarus project settings to appropriate FPC command-line options:
-M<mode>: Syntax mode-T<target>: Target OS-P<cpu>: Target CPU-Fu<path>: Unit search paths-Fi<path>: Include search paths-Fl<path>: Library search paths-FU<path>: Unit output directory-o<file>: Output file name