As the title states, code compiles, but won't load, stating "Error loading extension: res://bin/test.gdextension"
test.h:
#ifndef TEST_H
#define TEST_H
#include <godot_cpp/classes/node3d.hpp>
namespace godot {
class Test : public Node3D {
GDCLASS(Test, Node3D)
protected:
static void _bind_methods();
public:
Test();
~Test();
};
}
#endif // TEST_H
test.cpp:
#include "test.h"
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
void Test::_bind_methods() {
}
Test::Test() {
}
Test::~Test() {
}
register_types.h
#ifndef TEST_REGISTER_TYPES_H
#define TEST_REGISTER_TYPES_H
void initialize_test_module();
void uninitialize_test_module();
#endif // TEST_REGISTER_TYPES_H
register_types.cpp:
#include "register_types.h"
#include "test.h"
#include <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/godot.hpp>
using namespace godot;
void initialize_test_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
ClassDB::register_class<Test>();
}
void uninitialize_test_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
}
extern "C" {
// Initialization.
GDExtensionBool GDE_EXPORT test_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_test_module);
init_obj.register_terminator(uninitialize_test_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
}
test.gdextension:
[configuration]
entry_symbol = "test_library_init"
compatibility_minimum = "4.1"
[libraries]
macos.debug = "res://bin/libtest.macos.template_debug.framework"
macos.release = "res://bin/libtest.macos.template_release.framework"
windows.debug.x86_32 = "res://bin/libtest.windows.template_debug.x86_32.dll"
windows.release.x86_32 = "res://bin/libtest.windows.template_release.x86_32.dll"
windows.debug.x86_64 = "res://bin/libtest.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://bin/libtest.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://bin/libtest.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://bin/libtest.linux.template_release.x86_64.so"
linux.debug.arm64 = "res://bin/libtest.linux.template_debug.arm64.so"
linux.release.arm64 = "res://bin/libtest.linux.template_release.arm64.so"
linux.debug.rv64 = "res://bin/libtest.linux.template_debug.rv64.so"
linux.release.rv64 = "res://bin/libtest.linux.template_release.rv64.so"
android.debug.x86_64 = "res://bin/libtest.android.template_debug.x86_64.so"
android.release.x86_64 = "res://bin/libtest.android.template_release.x86_64.so"
android.debug.arm64 = "res://bin/libtest.android.template_debug.arm64.so"
android.release.arm64 = "res://bin/libtest.android.template_release.arm64.so"
SConstruct:
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["source/"])
sources = Glob("source/*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"bin/libtest.{}.{}.framework/libtest.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"bin/libtest{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)