godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.78k stars 3.07k forks source link

Errors when running commands described in GDExtensions C++ tutorial #7916

Open njelly opened 1 year ago

njelly commented 1 year ago

Your Godot version: 4.1

Issue description: GDExtension documentation commands lead to errors

URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html#doc-gdextension-cpp-example

I have followed these instructions up to this command: scons platform=<platform> -j4 custom_api_file=<PATH_TO_FILE>

It gives the following output:

C:\[REDACTED]\gdextension_cpp_example\godot-cpp>scons platform=windows -j4 custom_api_file="C:\[REDACTED]\gdextension_cpp_example\godot-cpp\extension_api.json"
scons: Reading SConscript files ...
Building for architecture x86_64 on platform windows
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src\godot.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -Igdextension -Iinclude -Igen\include src\godot.cpp
g++ -o src\classes\editor_plugin.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -Igdextension -Iinclude -Igen\include src\classes\editor_plugin.cpp
scons: *** [src\godot.windows.template_debug.x86_64.o] The system cannot find the file specified
g++ -o src\classes\low_level.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -Igdextension -Iinclude -Igen\include src\classes\low_level.cpp
g++ -o src\classes\wrapped.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -Igdextension -Iinclude -Igen\include src\classes\wrapped.cpp
scons: *** [src\classes\editor_plugin.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: *** [src\classes\wrapped.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: *** [src\classes\low_level.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: building terminated because of errors.

I have spent the time to make sure scons, cl, godot, etc., are all present in my Path.

EDIT: adding bits=64 to the command does not fix the error

paddy-exe commented 1 year ago

From what I gather of your trace low_level.cpp and wrapper.cpp should not be included as these files do not exist in the classes directory AFIK. Which headers did you include?

njelly commented 1 year ago

I have not included any headers, I am just going line by line through the tutorial described on that page. I have none of my own existing project code, in fact I am a novice to Godot entirely.

paddy-exe commented 1 year ago

Sorry I didn't mean to sound condescending in any way. I think you may need to check that you have

  1. the right Godot-cpp branch open
  2. you scons command path to the custom api file looks really weird like you are going out of the directory and back into it again.
  3. Why did you compile it with a custom file in the first place? You can compile for the latest stable release by git checkout-ing the 4.1 branch. Do you want to try out the master source version of Godot?

Side note: I would advise to get familiar with the engine first before trying out GDExtension.

njelly commented 1 year ago
  1. I am on branch 4.1 for the godot-cpp submodule
  2. How would it look for you if you ran it on your machine? I am not going out of any directory and back to it again, I am using an absolute file path to the extension_api.json file generated by the previous step (although the tutorial is not clear where this file should go).
  3. I'm unsure how to parse what you're saying here. What do you mean by custom file? I have not compiled anything yet. I am simply running the command that is described in the tutorial. I am trying to run it on the 4.1 branch and have a 4.1 godot executable downloaded and in my path as godot.
paddy-exe commented 1 year ago

The repository contains a copy of the metadata for the current Godot release, but if you need to build these bindings for a newer version of Godot, simply call the Godot executable:

godot --dump-extension-api extension_api.json

Place the resulting extension_api.json file in the project folder and add custom_api_file= to the scons command below.

The instructions are there. The path can be relative. To build godot-cpp you run the scons custom_api_file=<PATH_TO_FILE> inside godot-cpp to build the library. But that is ONLY needed for newer versions which aren't available as separate branches in the Godot-cpp repository. You can instead just run scons platform=<PLATFORM> -j4 in your case since you are building within the 4.1 branch.

elthundercloud commented 11 months ago

I'm also getting similar errors. All I'm doing here is running scons platform=windows in test directory. I can't open the included project either. My godot version is Godot_v4.1.1-stable, my godot-cpp tag is godot-4.1.1-stable. What's wrong? I believe I followed the steps as described.

scons: done reading SConscript files.
scons: Building targets ...
g++ -o W:\Projects\Godot\godot-cpp\src\godot.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -IW:\Projects\Godot\godot-cpp\gdextension -IW:\Projects\Godot\godot-cpp\include -IW:\Projects\Godot\godot-cpp\gen\include -IW:\Projects\Godot\godot-cpp\src W:\Projects\Godot\godot-cpp\src\godot.cpp
g++ -o W:\Projects\Godot\godot-cpp\src\classes\editor_plugin.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -IW:\Projects\Godot\godot-cpp\gdextension -IW:\Projects\Godot\godot-cpp\include -IW:\Projects\Godot\godot-cpp\gen\include -IW:\Projects\Godot\godot-cpp\src W:\Projects\Godot\godot-cpp\src\classes\editor_plugin.cpp
g++ -o W:\Projects\Godot\godot-cpp\src\classes\low_level.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -IW:\Projects\Godot\godot-cpp\gdextension -IW:\Projects\Godot\godot-cpp\include -IW:\Projects\Godot\godot-cpp\gen\include -IW:\Projects\Godot\godot-cpp\src W:\Projects\Godot\godot-cpp\src\classes\low_level.cpp
scons: *** [W:\Projects\Godot\godot-cpp\src\godot.windows.template_debug.x86_64.o] The system cannot find the file specified
g++ -o W:\Projects\Godot\godot-cpp\src\classes\wrapped.windows.template_debug.x86_64.o -c -std=c++17 -Wwrite-strings -O2 -DWINDOWS_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -IW:\Projects\Godot\godot-cpp\gdextension -IW:\Projects\Godot\godot-cpp\include -IW:\Projects\Godot\godot-cpp\gen\include -IW:\Projects\Godot\godot-cpp\src W:\Projects\Godot\godot-cpp\src\classes\wrapped.cpp
scons: *** [W:\Projects\Godot\godot-cpp\src\classes\editor_plugin.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: *** [W:\Projects\Godot\godot-cpp\src\classes\low_level.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: *** [W:\Projects\Godot\godot-cpp\src\classes\wrapped.windows.template_debug.x86_64.o] The system cannot find the file specified
scons: building terminated because of errors.

Edit: this issue was solved for me personally by reinstalling my compiler using visual studio installer. This isn't a guaranteed fix for the op though.

lokimckay commented 5 months ago

I had the same error using Godot 4.2 because I hadn't installed a C++ compiler yet, which provides the "g++" command seen in the output I followed an article which allowed me to install g++ version 6.3.0 but then I got different compiler errors which after googling I figured out was because I needed g++ version 7 or later

I downloaded version 13 from here and could successfully run the scons command in the godot docs tutorial

I think the docs should be updated to mention more about the C++ compiler requirement

Structed commented 1 month ago

I had a similar issue, because I only had a Preview version of Visual Studio installed. Installing a regular release version fixed my compile issues.