FPC (Free Pascal Compiler) is a Pascal compiler. You need a compiler, either FPC or Delphi, to build Castle Game Engine applications.
Our official downloads for Windows and Linux already include the most recommended (latest stable) FPC version, so you don't need to install FPC yourself. On other platforms, you need to install FPC yourself. Some of the options are:
Download and install from the FPC website.
Or download and install Lazarus along with FPC.
Or download and install both Lazarus and FPC using FpcUpDeluxe.
We always support and advice the latest stable release of FPC: right now this means 3.2.2.
Usually, we also support a couple of older FPC releases. Right now we support any FPC version >= 3.2.0.
Explanation and history: We use some modern Pascal features (like generics) in CGE, so we occasionally bump the required FPC version. We check what is commonly available, e.g. what is in the latest Debian stable (which is a baseline for many other Linux distros).
Special note if you want to build for Aarch64 (64-bit Arm), as found on Android, iOS, macOS: While we support any FPC >= 3.2.0, we strongly advise FPC >= 3.2.2. That is because certain optimizations have been broken in older FPC versions. Our build tool disables optimizations in released builds when it detects Aarch64 and older FPC.
Lazarus is an IDE (editor, debugger etc.) built around FPC. It also features a visual classes library (LCL) and an associated form designer.
Strictly speaking, you don't need Lazarus to use Castle Game Engine. You can use any editor to write Pascal code (e.g. VS Code) and compile your games using the engine editor and build tool which under the hood just call FPC (or Delphi) command-line compilers.
That said, of course you can use Lazarus with CGE, it's a feature-packed cross-platform comfortable IDE made for Pascal. Moreover, you need Lazarus if you want to
As for Lazarus version:
On Windows: We recommend Lazarus >= 3.2.
Older Lazarus versions have known issues:
On macOS, Linux, FreeBSD: We recommend Lazarus >= 3.5.
This means you should use Lazarus fixes_3_0
or main
branch from GitLab. It is easiest to use Lazarus from a branch using FpcUpDeluxe.
Unfortunately, last stable Lazarus 3.4 has 2 important bugs that affect CGE editor:
This fix (present in fixes_3_0
and main
branches) is critical on macOS: Tolerate AValue = nil in TCocoaWSCustomListView.SetImageList. Before this fix, trying to open any project (new or existing) will fail with SEGFAULT.
This fix (present in fixes_3_0
and main
branches) is critical on platforms using GTK2, like Linux and FreeBSD: Crash due to postponed focus loss (issue). Before this fix, editor occasionally crashes when renaming components in the tree (hierarchy) view.
Our Docker images right now include Lazarus versions with this issue patched by this diff.
To install multiple versions of FPC / Lazarus, with cross-compilers (e.g. for Android or iOS), use FpcUpDeluxe! We absolutely recommend and support it.
Some FPC libraries, like sparta_Docked
or sparta_Generics
, may contain their own copy of Generics.Collections
unit and friends.
FPC >= 3.2.0 doesn't need them (it contains the Generics.Collections
and friends, with the same implementation from Maciej Izak). In case of CGE, we didn't need them even for FPC 3.0.x, and CGE included our own copy of Generics.Collections
.
Solution: Remove Generics.Collections
and related units from any sparta_xxx
or other packages. FPC includes them already. Report to authors of these packages that these units create conflicts with FPC >= 3.2.0 standard units.
We generally try to support using the latest (unstable) FPC development version to compile CGE.
You can get such FPC:
Directly from GitLab (use main
branch to get really latest and unstable version)
or using FpcUpDeluxe
or using our Docker image.
Although by default we use latest stable FPC inside our Docker image, but you can get FPC unstable using the tag cge-none-fpc331
when requesting the image. So the full image name to get it from Docker Hub would be kambi/castle-engine-cloud-builds-tools:cge-unstable
.
The exact FPC revision included is the one listed in the Docker build script. This is updated manually from time to time (do you think we should bump it now? let us know).
Of course please remember that this FPC version is unstable, and it changes with every commit to FPC. We cannot test or guarantee that CGE works with an arbitray FPC development revision. But we welcome testing such FPC. PRs to make CGE work with latest FPC trunk are also welcome (unless there's a temporary bug in FPC which should be rather reported to FPC devs).
We moved our Delphi documentation to a separate page.
We do not support using Code Typhon (a fork of FPC/Lazarus).
We advise that you rather use original FPC and Lazarus. We have more trust in FPC and Lazarus developers doing great quality job, respecting copyrights of other projects (CodeTyphon did some murky things), and working in a transparent fashion (version control, cooperating with other projects).
Note that Lazarus comes now with Online Package Manager. And you can use FpcUpDeluxe to easily install cross-compilers. These cover the most often cited reasons for using Code Typhon in the past.