Setting up Visual Studio 2022 Intellisense for making a GDExtension

Godot Version

4.4

Question

Howdy, I’m trying to make an extension for the first time and I’m on Windows 10.

I cloned godot-cpp using the template repository, renamed the placeholder strings in the template, and built the project using Scons. I was able to launch the project’s example scene and it printed the expected output of Type: 24.

I want to use Visual Studio 2022 to write my extension code, but I don’t know how to set it up so that Intellisense is aware of godot-cpp files. I found this page explaining how to build a Visual Studio solution using Scons, but it looks like it was meant for editing the actual engine and not for writing an extension through godot-cpp.

I couldn’t find out how to do this myself, so my questions are:

  • Should I be creating a new blank C++ project in Visual Studio, or should I be generating a solution file some other way?
  • How should I set up my folder structure? It looks like godot-cpp wants me to put my class files in /src, but creating a new Visual Studio project within my local godot-cpp repo creates its own folders.
  • After all that, how do I get Intellisense to work?

Thanks!

1 Like

In my environment, I generated a visual studio solution using “File tab → new → project from existing code”.
In project settings window, I selected “Use external build system”.
This should create the project solution.

Next, it would be setting build commands and IntelliSense.
You need to navigate to solution properties.
in “solution explorer” dock, right-click your solution, select properties.
Find NMake configuration section.

You may configure “Build Command Line” with scons [your-args]
or “Clean Command Line” with scons [your-args] --clean
and for IntelliSense, I added the following entries to “Include Search Path” then the navigation and autocompletion in the editor were configured:

src
godot-cpp\include
godot-cpp\gen\include
godot-cpp\gdextension

Note: the headers in godot-cpp\gen\include will be generated when the build command is executed at least one time. Also, these are deleted when running scons with --clean argument.

1 Like

Thank you for making an account just to answer my question!

I followed your instructions and got it working, but I have a few more questions:

  • My solution’s Configuration Properties only contains an NMake section if the Platform is set to Win32. Is this normal?

  • Many references were missing when I opened any class’s file. With the Configuration Properties’s platform set to Active(x64), adding your entries:

    src
    godot-cpp\include
    godot-cpp\gen\include
    godot-cpp\gdextension
    

    to Configuration Properties > C/C++ > General > Additional Include Directories fixed the missing references and also enabled Intellisense, without having to add the entries to Include Search Path. Should I still add them there too?

  • Also was the entry scr supposed to be src?

Thanks again!

1 Like

You are welcome!

I would say “Use external build system” was not included during “project from existing code” process or visual studio cannot recognize it as Makefile project because it cannot locate build systems components. I can see it uses C\C++ template instead of Makefile template. That is why you cannot find “NMake” section and find instead “C/C++” section.

No, this is enough for IntelliSense. Although, it would be harder to configure your environment for debugging.
Makefile template makes this easier by just configuring “Build Command Line” and “Output“ in “NMake“ section along with “Debugging” section in “Configuration Properties“.

I currently do not have a debug environment for GDExtension source like the one I have for Godot source. But when I setup one, I might automate this process using python and make a pull request.

Yes, it should be src!