GD Extension - CMake - Problems

Godot Version

4.6.1

I keep having trouble using CMake to build a GDExtension.

I’m trying to get an extension to build using CMake and scons, however CMake behaves unpredictably. Before I’ve had it where suddenly CMake would stop working with a message of

Cannot generate into /home/jordan/Code/CPP/gd_one/godot-cpp-template
It was created with incompatible generator 'Unix Makefiles'

Please either delete it manually or select another generation director

When it had been working the day before, and now today I added some code, checked that things were working. And then decided to try and adjust the SConstruct file to try and get things to build and work using scons as well. However after the failed scons build, the CMake project no longer works. It compiles, but when loaded in Godot it starts throwing errors.

ERROR: Condition "!FileAccess::exists(path)" is true. Returning: ERR_FILE_NOT_FOUND
   at: open_dynamic_library (drivers/unix/os_unix.cpp:1061)
ERROR: Condition "!FileAccess::exists(path)" is true. Returning: ERR_FILE_NOT_FOUND
   at: open_dynamic_library (drivers/unix/os_unix.cpp:1061)
ERROR: GDExtension dynamic library not found: 'res://bin/example.gdextension'.
   at: open_library (core/extension/gdextension.cpp:740)
ERROR: Error loading extension: 'res://bin/example.gdextension'.

However the loaded project does have the file:

But if I click on the file I get this error:

  ERROR: drivers/unix/os_unix.cpp:1061 - Condition "!FileAccess::exists(path)" is true. Returning: ERR_FILE_NOT_FOUND
  ERROR: drivers/unix/os_unix.cpp:1061 - Condition "!FileAccess::exists(path)" is true. Returning: ERR_FILE_NOT_FOUND
  ERROR: GDExtension dynamic library not found: 'res://bin/example.gdextension'.
  ERROR: Failed loading resource: res://bin/example.gdextension.
  ERROR: editor/editor_node.cpp:1628 - Condition "res.is_null()" is true. Returning: ERR_CANT_OPEN

I checked the content of the file and it looks fine. Any idea what caused this problem? Or how I can fix it? I used git to roll back all today’s changes but the problem persists.

i see two separate problems.

example.gsextension file tells godot where to find the extension library, its in plain text so open it to see what godot is looking for.

you aren’t properly cleaning up, godot ignores files, git ignores files

so lookup how to reset your source tree including untracked files, delete cmake’s build folder, etc

First of all calling cmake on the build directory with --target clean has no effect on the problem , neither does resetting the cmake cache so it’s not to do with cmake not being “cleaned” properly.

However in case I am wrong can you point me to the docs that describe the proper cleanup as you refer to it, as I don’t see anything here that says specific cleanup steps are needed:

Secondly I did nothing to change anything with cmake at all, the problem just suddenly appeared, one minute it worked fine, the next it had these errors.

I know the file is plain text, note my original post that says I opened the file and it’s contents are basically the same as every other gdextension I built, only the entry point and lib name are different between the different extensions.

Thanks for replying but your post was less than helpful.