Trying to Compile Godot with SCons is not Easy

For many developers, setting up the tooling and dependencies necessary in order to compile custom versions of Godot Engine is a hassle.
That’s so true.
I’m still trying.

Generate The Glue

The glue sources are the wrapper functions that will be called by the managed side. In order to generate them, first, you must build Godot with the options tools=yes and mono_glue=no:

scons p=windows tools=yes module_mono_enabled=yes mono_glue=no

After the build finishes
What if the build does not finish, but returns an error:

RuntimeError(“Mono glue sources not found. Did you forget to run ‘–generate-mono-glue’?”)

I tried the command - mono --generate-mono-glue, and got Unknown command line option: ‘–generate-mono-glue’.

Did I do something wrong? What do I need to do, please? Thank you.

The easiest way to get your dependencies in order seems to be to just use the visual studio installer, and modify the installed packages.
If you install the “Desktop Development with C++” and “Game development with C++” package, you should have all?/most of the dependencies you need to run scons for godot correctly.
You also need scons installed and I think python 3.9.
Also, the first time compiling it takes a long time.

Have you tried that?

Thanks for your response.

The easiest way to get your dependencies in order seems to be to just use the visual studio installer, and modify the installed packages.
If you install the “Desktop Development with C++” and “Game development with C++” package, you should have all?/most of the dependencies you need to run scons for godot correctly.
In theory, that doesn’t look like the ‘easiest way’, because I don’t have a clue what ‘modify the installed packages’ means in practice, and I don’t have a mental picture of what modifications would be required, and how much time would be required.

The Godot documentation reads:

Building from source

Godot prides itself on being very easy to build, by C++ projects’ standards. Godot uses the SCons build system, and after the initial setup compiling the engine for your current platform should be as easy as running:

Development in Visual Studio

Using an IDE is not required to compile Godot, as SCons takes care of everything. But if you intend to do engine development or debugging of the engine’s C++ code, you may be interested in configuring a code editor or an IDE.

Folder-based editors don’t require any particular setup to start working with Godot’s codebase. To edit projects with Visual Studio they need to be set up as a solution.

You can create a Visual Studio solution via SCons by running SCons with the vsproj=yes parameter, like this:

scons p=windows vsproj=yes

You will be able to open Godot’s source in a Visual Studio solution now, and able to build Godot using Visual Studio’s Build button.

The GameFromScratch guy gave an example, on Godot and Visual Studio, and that was simply opening a Visual Studio command prompt, which helped me out, and running SCons.

I understand persons may have their own workarounds that works for them, and yours might actually work, so I appreciate that, thanks.
However, my vision is totally blank on what ‘modify the installed packages’ looks like, and there is no documentation to work with.

You also need scons installed and I think python 3.9.

It works with version 3.7

Also, the first time compiling it takes a long time.
Have you tried that?

I left it running, while I slept, and woke up to this. Twice.

[Initial build] ←[0;94mCompiling ←[1;94mdrivers\coremidi\midi_driver_coremidi.cp
p←[0;94m ...←[0m
drivers\wasapi\audio_driver_wasapi.cpp(106): error C2065: 'IAudioClient3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(106): error C2737: 'IID_IAudioClient3': const object must be initialized
drivers\wasapi\audio_driver_wasapi.cpp(322): error C2065: 'IAudioClient3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(322): error C2059: syntax error: ')'
drivers\wasapi\audio_driver_wasapi.cpp(405): error C2065: 'IAudioClient3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(405): error C2065: 'device_audio_client_3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(405): error C2065: 'IAudioClient3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(405): error C2059: syntax error: ')'
drivers\wasapi\audio_driver_wasapi.cpp(413): error C2065: 'device_audio_client_3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(440): error C2065: 'device_audio_client_3': undeclared identifier
drivers\wasapi\audio_driver_wasapi.cpp(449): error C2065: 'device_audio_client_3': undeclared identifier
scons: *** [drivers\wasapi\audio_driver_wasapi.windows.editor.dev.x86_64.obj] Error 2
midi_driver_coremidi.cpp
scons: building terminated because of errors.
[Time elapsed: 01:00:25.859]

These are same errors, I came to these forums to get help with, 4 days ago.
Errors Using SCons to Create a VS Solution

just use the visual studio installer

I just realized, you seem to be referring to Visual Studio Code, rather than Visual Studio.
There isn’t a Visual Studio installer, so I am trying to generate one.

No no, I meant visual studio, not code. Although there might be a package in Code that does a similar thing.

I’d suggest you try to follow a video tutorial about how to compile it.
Most of them uses the Visual Studio package to install dependencies so I think that should be the simpler solution.

Here is where the “modify packages” that you need is:

Oh. You meant install Visual Studio.
Visual Studio is already installed.

Perhaps I wasn’t clear on my objective, or what I already did.

Importing the project

Visual Studio requires a solution file to work on a project. While Godot does not come with the solution file, it can be generated using SCons.

Navigate to the Godot root folder and open a Command Prompt or PowerShell window.
Run scons platform=windows vsproj=yes dev_build=yes to generate the solution with debug symbols.
The vsproj parameter signals that you want Visual Studio solution generated.
The dev_build parameter makes sure the debug symbols are included, allowing to e.g. step through code using breakpoints.

You can now open the project by double-clicking on the godot.sln in the project root or by using the Open a project or solution option inside of the Visual Studio.

Use the Build top menu to build the project.

I have tried this, but getting errors, as I posted here.

What is my purpose for wanting to develop the engine?

Custom modules in C++

Modules

Godot allows extending the engine in a modular way. New modules can be created and then enabled/disabled. This allows for adding new engine functionality at every level without modifying the core, which can be split for use and reuse in different modules.

Modules are located in the modules/ subdirectory of the build system. By default, dozens of modules are enabled, such as GDScript (which, yes, is not part of the base engine), the Mono runtime, a regular expressions module, and others. As many new modules as desired can be created and combined. The SCons build system will take care of it transparently.

What for?

While it’s recommended that most of a game be written in scripting (as it is an enormous time saver), it’s perfectly possible to use C++ instead. Adding C++ modules can be useful in the following scenarios:

  • Binding an external library to Godot (like PhysX, FMOD, etc).
  • Optimize critical parts of a game.
  • Adding new functionality to the engine and/or editor.
  • Porting an existing game to Godot.
  • Write a whole, new game in C++ because you can’t live without C++.

The video doesn’t really add anything, except give me the idea to try the master branch. So I downloaded the zip file, instead of cloning.

It’s been building now, looks like nearly two hours.
So, if it doesn’t give any errors, I’ll know that the problem is with both the 5.3.5, and 4.2.1 stable branches.

Hopefully tthat’s the case, because this is quite a long build.
I never had an engine build this long, since Lumberyard, and that was, before they got past beta.

Thanks though. Not what I was asking, but it may… may have helped. I had given up.

Well, it did build successful, after 4 hours and 46 minutes.

[Initial build] scons: done building targets.
[Time elapsed: 04:46:36.072]

So, the problem seems to be with the stable branches.
I tried to build the godot-4.2.1-stable branch, and it failed with errors.

navigation_server_3d.windows.editor.dev.x86_64.obj : fatal error LNK1000: Internal error during BuildLibrary.EmitMember
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\debug.c←[0;94m ...←[0m
debug.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\entropy_common.c←[0;94m ...←[0m
entropy_common.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\error_private.c←[0;94m ...←[0m
error_private.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\fse_decompress.c←[0;94m ...←[0m
fse_decompress.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\pool.c←[0;94m ...←[0m
pool.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\threading.c←[0;94m ...←[0m
threading.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\xxhash.c←[0;94m ...←[0m
xxhash.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\common\zstd_common.c←[0;94m ...←[0m
zstd_common.c
[Initial build] ←[0;94mCompiling ←[1;94mthirdparty\zstd\compress\fse_compress.c←
[0;94m ...←[0m
scons: *** [servers\servers.windows.editor.dev.x86_64.lib] Error 255
fse_compress.c
scons: building terminated because of errors.
[Time elapsed: 02:57:56.740]

I’ll try the 3.5.3 later, to make doubly sure.

Okay, something is wrong with these.

[Initial build] scons: *** [modules\gltf\editor_scene_importer_gltf.windows.tool
s.64.obj] C:\develop\godot\3.5.3\godot\modules\gltf\editor_scene_importer_gltf.cpp:
Permission denied
scons: building terminated because of errors.
[Time elapsed: 00:24:01.838]

I’ll stick with the master branch.