godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.66k stars 502 forks source link

Fatal error C1083: Cannot open include file: 'Godot.hpp': No such file or directory #380

Open GittyGrubHub85 opened 4 years ago

GittyGrubHub85 commented 4 years ago

I'm using GDNative documentation of Godot 3.2 and I'm stuck on this section (Compiling the Plugin): https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html#compiling-the-plugin

Here's the build log:

scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... scons: `bin\libgodot-cpp.windows.debug.default.lib' is up to date. cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -W3 -GR -EHsc -MDd -ZI /DWIN32 /D_WIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /D_DEBUG /I. /Igodot-cpp\godot_headers /Igodot-cpp\include /Igodot-cpp\include\core /Igodot-cpp\include\gen /Isrc gdexample.cpp e:\godot\godot 3.2\projects (own)\gdnative c++ based on documents\gdnative_cpp_example\godot-cpp\src\gdexample.h(4): fatal error C1083: Cannot open include file: 'Godot.hpp': No such file or directory scons: *** [src\gdexample.obj] Error 2 scons: building terminated because of errors.

As I compiled with scons, it throws me the error of No such file or directory. I've already generate its bindings including Godot.hpp

I'm using Visual Studio code with this and it can detect Godot.hpp and throws no errors but it throws errors on cmd scons command

I'm I missing something?

In this current section, my new SConstruct file was been combined with the old.

Zylann commented 4 years ago

In your SConstruct file, look at the lines with env.Append(CPPPATH. These lines add directories for the compiler to look for header files. Among others, you should be able to find a path to the directory containing Godot.hpp. Make sure it has the correct paths.

For example, mine:

env.Append(CPPPATH = [
    '.', 
    'godot-cpp/godot_headers/', 
    'godot-cpp/include/', 
    'godot-cpp/include/core/', 
    'godot-cpp/include/gen/'
])

And my directory structure: image Note: my SConstruct is separate from the godot-cpp one.

Zylann commented 3 years ago

Is this still an issue? Typically this is due to your SConstruct file specifying the wrong path to the C++ bindings.

Zylann commented 3 years ago

Same thing, check your include paths. Recently godot-headers was renamed with a - instead of an _ so make sure your paths are correct. (see also https://github.com/godotengine/godot-cpp/issues/523)

kburchfiel commented 2 years ago

I'm not seeing a file called Godot.hpp within my folders. There is one named godot.hpp, however. Could this difference in capitalization be part of the reason why I'm getting a similar error?

Zylann commented 2 years ago

The answers I gave were for GDNative in Godot 3. This might not apply 1:1 to the master branch which is now GDExtension for Godot 4. But in general if your compiler cannot find a header it is also because of a similar problem: header paths in your build script need a fix to contain the right directories (as when using any C++ library generally)

Antoner8 commented 2 years ago

i dont have any godot.hpp or Godot.hpp file

mistermeman commented 4 months ago

Hi,

I don't seem to have a "Nativ"-directory. Is that bad? (LoL)

Also I attempted togit copy the Godot-cpp repository with Git Bash but it came without headers, so I git copy the headers repository too, both via http. Is there a better way to do this?

BTW I downloaded the Godot-cpp 4.2-Version and use the Godot 4.2.1-Version. Does that make sense or should I use master branch instead? However I had the exact same problem with master branch.

dsnopek commented 4 months ago

@mistermeman The headers repository isn't used with Godot 4, that's a Godot 3 thing. The headers are generated as part of the build process, running scons should automatically generate them.