In short: you need sudo apt install libgtk2.0-dev.
Longer explanation: when linking applications that use GTK 2, the Unix linker needs a file libgtk-x11-2.0.so (just .so extension, no extra numbers afterwards). This file is installed on Debian-based Linux distros by package libgtk2.0-dev, and it is a symlink to the actual GTK library.
This is how it should look once you install libgtk2.0-dev:
$ cd /usr/lib/x86_64-linux-gnu
$ ls -Flah libgtk-x11-2.0.so*
lrwxrwxrwx 1 root root 27 lip 15 2024 libgtk-x11-2.0.so -> libgtk-x11-2.0.so.0.2400.33
lrwxrwxrwx 1 root root 27 lip 15 2024 libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.33
-rw-r--r-- 1 root root 4,5M lip 15 2024 libgtk-x11-2.0.so.0.2400.33
When linking, the linker actually records in the Linux exe the information that it is linked with /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0. That is, linker looks at where the symlink points to, and records the version of file with one extra number .0, which in theory can be incremented on incompatible GTK changes (in practice, GTK 3 has a different naming altogether). You can confirm it by inspecting the build lazarus executable file (once you successfully make it) with ldd, like
$ ldd lazarus
....
libgtk-x11-2.0.so.0 => /lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (...)
...
The libgtk-x11-2.0.so.0 is provided by other package that is almost for sure already installed on your system (esp. since you run fpcupdeluxe which itself uses GTK 2). On Ubuntu it is libgtk2.0-0t64, in general it’s called like libgtk2.0* but without any -dev suffix.
So regular users (that just run applications using GTK 2, don’t link such applications) don’t need the libgtk2.0-dev package. They only need the version of the file with .0 suffix, from package like libgtk2.0-0t64 (installed by default on ~most Linux distros I guess). You need to install libgtk2.0-dev to be able to link applications using GTK 2, not only execute them.
Note that Castle Game Engine requirements also mention this package: Compiling from source | Manual | Castle Game Engine . Although we also recommend libgtk-3-dev since we migrated to GTK 3 so your typical CGE applications will use GTK 3, not GTK 2.