It is possible to compile and run on the Raspberry Pi 4. Raspberry Pi is not an officially supported platform, but you can still build a usable version of Godot. Compiling is a bit tricky though: you have to specify several options to the scons
build system. Luckily, I've managed to find information scattered around the internet.
You'll need to install the packages
build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libxi-dev libxrandr-dev clang
I didn't install libudev-dev
and yasm
as they are optional dependencies. yasm
gives WebM SIMD optimisations. The WebM module seems to cause errors when building with it. Installing clang
is crutial, as the GCC version provided on Raspbian Raspberry Pi OS is too old, < 8.4. Note that on the docs, it is written that GCC >= 7 is required, but the build system will complain about a version older than 8.4.
You also have to change the scons
script file:
If your distribution uses Python 2 by default, or you are using a version of SCons prior to 3.1.2, you will need to change the version of Python that SCons uses by changing the shebang (the first line) of the SCons script file to
#! /usr/bin/python3
. Use the commandwhich scons
to find the location of the SCons script file.
I'd recommend cloning the Godot source files on an external hard-drive, as it can be quite big.
git clone https://github.com/godotengine/godot.git
Checking out to a stable release is essential. I checked-out to the tag 3.2-stable
.
Godot uses the scons
build system. More information about it can be found in the Godot documentation. I've managed to build Godot 3.2 with this command line. YMMV for other versions, you might have to do some simple adjustments. You shouldn't compile with root!
scons -j4 platform=x11 target=release_debug use_llvm=yes tools=yes module_mono_enabled=no module_webm_enabled=no CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"
platform=x11
: I tried to select the linuxbsd
platform but I got an error message that it is incorrect. In the list of possible choices were x11
, I choose that, as we are building for the xorg graphical platform. Weirdly enough, when I accidentally wanted to build the master
branch, I didn't get an error when specifying linuxbsd
as the platform.target=release_debug
: Assertions are still done for this target, but debugging symbols are stripped, resulting in better performance.use_llvm=yes
: we want to compile with clang, as the GCC version installed is too old.tools=yes
: build the Godot editor.module_mono_enabled=no
: I don't use C#. :p You could still try enabling that…module_webm_enabled=no
: Enabling the WebM module seems to cause problems.CCFLAGS="..."
: Required to compileTo have an optimized build, you can enable LTO, with use_lto=yes
. This will require about 3 GB of memory and seems to only be for GCC.
I built Godot 3.2.1 and 3.2 with:
scons -j4 platform=x11 target=release_debug use_llvm=yes tools=yes module_mono_enabled=no module_webm_enabled=no CCFLAGS="-mcpu=cortex-a72 -mfpu=neon-armv8 -mfloat-abi=hard -mtune=cortex-a72"
It took this much time
on a Raspberry Pi 4. Note that I didn't compile from scratch.
Someone managed to compile Godot with alternative CCFLAGS. The person specified the Cortex A72 as CPU instead of the Cortex A7.
But i tried a little bit differend compile command than all others talk about. I found out, that i get a lot of neon-vfpv4 related compiler errors. The compile command that runs without errors I came up is:
scons platform=x11 target=release tools=no use_llvm=yes CCFLAGS="-mtune=cortex-a72 -mcpu=cortex-a72 -mcfpu=neon-fp-armv8 -mfloat-abi=hard" -j4
You can delete the object files with scons --clean
, if you wish to save space.
The binary is in the bin
folder. It has no dependencies.
When running, I get errors. The program still runs correctly. A small extract of the errors that I get is available below. Note that I do not get all these errors at the same moment. Some of them seem to exist because of OpenGL driver problems.
ERROR: initialize: Condition "ctxErrorOccurred || !p->glx_context" is true. Returned: ERR_UNCONFIGURED
At: platform/x11/context_gl_x11.cpp:190.
ERROR: store_buffer: Condition "!p_src" is true.
At: drivers/unix/file_access_unix.cpp:278.
ERROR: is_viable: Error initializing GLAD
At: drivers/gles3/rasterizer_gles3.cpp:141.
ERROR: get_meta: Condition "!metadata.has(p_name)" is true. Returned: Variant(
At: core/object.cpp:1047.
When trying to run a scene, you might get an error about an unavailable video driver. Change the video driver to GLES2
by going into "Project settings / Rendering / Quality / Driver name".
Hopefully, this should help someone!
All the sources that helped me understand how to build Godot for the Raspberry Pi 4. There are also tickets for existing problems that affect Raspberry Pi 4.