Compiling with Mono¶
- Mono 5.12.0 or greater
You may need to import necessary certificates for NuGet to perform HTTPS requests. You can do this with the following command (on Windows, you can run it from the Mono command line prompt):
mozroots --import --sync
By default, SCons will try to find Mono in the Windows Registry on Windows or via
pkg-config on other platforms. You can specify a different installation directory by using the following environment variables for the respective
The specified directory must contain the subdirectories
Enable the Mono module¶
By default, the mono module is disabled for builds. To enable it you can pass the option
module_mono_enabled=yes to your SCons command.
Generate the glue¶
The glue sources are the wrapper functions that will be called by managed methods. These source files must be generated before building your final binaries. In order to generate them, first, you must build a temporary Godot binary with the options
scons p=<platform> tools=yes module_mono_enabled=yes mono_glue=no
After the build finishes, you need to run the compiled executable with the parameter
--generate-mono-glue followed by the path to an output directory. This path must be
modules/mono/glue in the Godot directory.
<godot_binary> --generate-mono-glue modules/mono/glue
This command will tell Godot to generate the file
Once this file is generated, you can build Godot for all the desired targets without the need to repeat this process.
<godot_binary> refers to the tools binary you compiled above with the Mono module enabled.
Its exact name will differ based on your system and configuration, but should be of the form
Be especially aware of the .mono suffix! If you compiled Godot without Mono support previously, you might have similarly named binaries without this suffix which can't be used to generate the Mono glue.
- Do not build your final binaries with
mono_glue=no. This disables C# scripting. This option must be used only for the temporary binary that will generate the glue. Godot will print a warning at startup if it was built without the glue sources.
- The glue sources must be regenerated every time the ClassDB bindings changes. That is, for example, when a new method is added to ClassDB or one of the parameter of such a method changes. Godot will print an error at startup if there is an API mismatch between ClassDB and the glue sources.
Rebuild with Mono glue¶
Once you have generated the Mono glue, you can build the final binary with
It's the default value for
mono_glue so you can also omit it. You can build the Mono-enabled editor:
scons p=<platform> tools=yes module_mono_enabled=yes mono_glue=yes
And Mono-enabled export templates:
scons p=<platform> tools=no module_mono_enabled=yes mono_glue=yes
If everything went well, apart from the normal output SCons should have created the following files in the
- If you're not static linking the Mono runtime, the build script will place the Mono runtime shared library next to the Godot binary.
- Unlike "classical" Godot builds, when building with the mono module enabled a data directory will be created both for the editor and for export templates. This directory is important for proper functioning and must be distributed together with Godot. More details about this directory in Data directory.
# Build temporary binary scons p=windows tools=yes module_mono_enabled=yes mono_glue=no # Generate glue sources bin\godot.windows.tools.64.mono --generate-mono-glue modules/mono/glue ### Build binaries normally # Editor scons p=windows target=release_debug tools=yes module_mono_enabled=yes # Export templates scons p=windows target=debug tools=no module_mono_enabled=yes scons p=windows target=release tools=no module_mono_enabled=yes
# Build temporary binary scons p=x11 tools=yes module_mono_enabled=yes mono_glue=no # Generate glue sources bin/godot.x11.tools.64.mono --generate-mono-glue modules/mono/glue ### Build binaries normally # Editor scons p=x11 target=release_debug tools=yes module_mono_enabled=yes # Export templates scons p=x11 target=debug tools=no module_mono_enabled=yes scons p=x11 target=release tools=no module_mono_enabled=yes
The data directory is a dependency for Godot binaries built with the mono module enabled. It contains files that are important for the correct functioning of Godot. It must be distributed next to the Godot executable.
The name of the data directory for a export template differs based on the configuration it was built with. The format is
In the case of export templates the data directory only contains Mono framework assemblies and configuration files, as well as some shared library dependencies like
This directory must be placed with its original name next to the Godot export templates. When exporting a project, Godot will also copy this directory with the game executable but the name will be changed to
<APPNAME> is the application name as specified in the project setting
In the case of macOS, where the export template is compressed as a zip file, the contents of the data directory can be placed in the following locations inside the zip:
The name of the data directory for the Godot editor will always be
GodotSharp. The main structure of this directory has the following subdirectories:
Tools subdirectory contains tools required by the editor, like the
Mono subdirectory is optional. It can be used to bundle the Mono framework assemblies and configuration files with the Godot editor, as well as some shared library dependencies like
MonoPosixHelper. This is important to avoid issues that might arise when the installed Mono version in the user's system may not be the same as the one the Godot editor was built with. You can make SCons copy these files to this subdirectory by passing the option
copy_mono_root=yes when building the editor.
Api directory is also optional. Godot API assemblies are not bundled with the editor by default. Instead the Godot editor will generate and build them on the user's machine the first time they are required. This can be avoided by generating and building them manually and placing them in this subdirectory. If the editor can find them there, it will avoid the step of generating and building them again.
The following is an example script for building and copying the Godot API assemblies:
The script assumes it's being executed from the directory where SConstruct is located.
<godot_binary> refers to the tools binary compiled with the Mono module enabled.
In the case of macOS, if the Godot editor is distributed as a bundle, the contents of the data directory may be placed in the following locations:
명령 줄 설정¶
The following is the list of command-line options available when building with the mono module:
- module_mono_enabled: Build Godot with the mono module enabled ( yes | no )
- mono_glue: Whether to include the glue source files in the build and define MONO_GLUE_DISABLED as a preprocessor macro ( yes | no )
- xbuild_fallback: Whether to fallback to xbuild if MSBuild is not available ( yes | no )
- mono_static: Whether to link the mono runtime statically ( yes | no )
- copy_mono_root: Whether to copy the Mono framework assemblies and configuration files required by the Godot editor ( yes | no )