Error when compiling Godot C++ using Linux terminal

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BlueLightningWizard

Hello, I am new to compiling so I have no idea on how to properly compile a program using Linux terminal.
I had followed the instructions that were provided here (Godot Docs) - GDNative C++ Example

Given below are the commands I had written (by copying) after referring to the instructions -

  1. mkdir GDNative (‘GDNative’ is the name of the directory, instead of ‘gdnative_cpp_example’ that was given in Godot Docs)
  2. cd GDNative
  3. git clone --recursive -b 3.x
  4. git submodule update --init --recursive
    (The ‘api.json’ file is in the godot-headers sub-folder in godot-cpp folder, but there is another api.json file 'gdnative_api.json)
  5. use_custom_api_file=yes custom_api_file=../api.json (I didn’t know what exactly I had to do with this commmand, but there was no error in the command once I entered)
    The next step is where I found the error. I tried to solve it but failed.
  6. scons platform=linux generate_bindings=yes -j8

The following code is where the error was mentioned-

scons: Reading SConscript files ...
src/gen: File exists
src/gen: File exists
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/core/AABB.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/AABB.cpp
sh: 1: g++: not found
g++ -o src/core/Array.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/Array.cpp
g++ -o src/core/Basis.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/Basis.cpp
sh: 1: g++: not found
sh: 1: g++: not found
g++ -o src/core/CameraMatrix.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/CameraMatrix.cpp
sh: 1: g++: not found
g++ -o src/core/Color.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/Color.cpp
sh: 1: g++: not found
g++ -o src/core/Dictionary.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/Dictionary.cpp
sh: 1: g++: not found
g++ -o src/core/GodotGlobal.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/GodotGlobal.cpp
sh: 1: g++: not found
scons: *** [src/core/AABB.o] Error 127
scons: *** [src/core/Array.o] Error 127
scons: *** [src/core/Basis.o] Error 127
scons: *** [src/core/CameraMatrix.o] Error 127
scons: *** [src/core/Color.o] Error 127
scons: *** [src/core/Dictionary.o] Error 127
scons: *** [src/core/GodotGlobal.o] Error 127
g++ -o src/core/NodePath.o -c -fPIC -std=c++14 -Wwrite-strings -Og -g -m64 -I. -Igodot-headers -Iinclude -Iinclude/gen -Iinclude/core src/core/NodePath.cpp
sh: 1: g++: not found
scons: *** [src/core/NodePath.o] Error 127
scons: building terminated because of errors.

Another thing - how can I download Godot 3.x executable? Is the game engine itself the executable. If yes, then the game engine is actually outside the ‘GDNative’ folder. Can someone help me in compiling Godot C++ in a simple way, while solving the problem?

Thanks in advance.

:bust_in_silhouette: Reply From: r.bailey

A couple of things, the main engine project in its current form version 3.4.* and below there are separate projects for different things. The main game engine can be built and pulled down at different version from the git repo below, if you need a different version, that you want to just download the .exes you can find and download them on the releases.

If you want to builds specific version of the engine from the source code you can get the version from the switch version and go to tags and select the tag for the version you want that was release.

Godot Engine Github

Now for GDNative you need a seperate repo, which is not the engine, but the bindings to be able to use GDNative(seperate dll’s for logic to tie into the engine). This requires the headers folder for the exact version that you have.(I assume you are not building your own custom engine so things like use_custom_api_file=yes are not necessary and you should not be using that.) The main thing with the godotcpp lib is that the header files are there and properly pulled down, that is most likely what your errors are above.

I think your step 4 might be pulling down the most recent headers(which would be master). You should only need step 1-3 and then step 6 to build the bindings.(As noted above this is not the main engine, but a submodule of it to link dll’s.)

Hope this helps and leads you in the write direction.

So, what I need to do is to follow steps 1-3 and then directly to step 6? I’ll try. Thanks for your answer. Hope it works.

BlueLightningWizard | 2022-03-18 20:03

It didn’t work,
Can you properly explain on how to install a C++ build, if you don’t mind, in simple words?
And sorry for inconvenience.

BlueLightningWizard | 2022-03-18 20:21