Godot Version
Godot 4.2.2
Question
Hello,
I’m trying to wrap one of my C++ Libraries to use in GDScript.
I have a data class that looks something like this:
class Moment : public godot::Object
{
GDCLASS(Moment, godot::Object)
public:
godot::Vector3 getPose();
....
protected:
void _bind_methods();
private:
std::vector<Eigen::Vector2f> measurements;
Eigen::AffineCompact2f pose;
};
this class holds LiDAR (Laser Scans of an Environment) data which I’d like to display in Godot, thus I’ve created a secondary class called MomentManager
that loads the data from a file and should make it available to GDScript its interface looks something like:
class MomentManager : public godot::Object
{
GDCLASS(MomentManager, godot::Object)
public:
void load_from_file(String path);
Moment at(size_t index);
protected:
void _bind_methods();
private:
std::vector<Moment> moments;
};
But as soon as I try to register the MomentManager::at()
method I get a compile error. Everything else works just fine.
I’m using CMake.
Compile Error:
[main] Building folder: visualizer
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build visualizer/build --config Debug --target all --
[build] [1/2 0% :: 0.036] Re-checking globbed directories...
[build] [1/3 33% :: 2.714] Building CXX object src\CMakeFiles\mog-slam-visualizer.dir\godot-extension\MomentsManager.cpp.obj
[build] FAILED: src/CMakeFiles/mog-slam-visualizer.dir/godot-extension/MomentsManager.cpp.obj
[build] C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\cl.exe /nologo /TP -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DTYPED_METHOD_BIND -Dmog_slam_visualizer_EXPORTS -Ibuild\app_config -Isrc -Ibuild\_deps\mogs-src\src -Ibuild\_deps\mogs-build\src -Ibuild\_deps\mogs-src\libraries\cereal\include -external:Ibuild\_deps\godot-cpp-src\include -external:Ibuild\_deps\godot-cpp-build\gen\include -external:Ibuild\_deps\godot-cpp-src\gdextension -external:Ibuild\_deps\mogs-src\libraries\Eigen3 -external:W0 /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++latest -MDd /bigobj /D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS /showIncludes /Fosrc\CMakeFiles\mog-slam-visualizer.dir\godot-extension\MomentsManager.cpp.obj /Fdsrc\CMakeFiles\mog-slam-visualizer.dir\ /FS -c src\godot-extension\MomentsManager.cpp
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/method_bind.hpp(556): error C2027: use of undefined type 'godot::GetTypeInfo<R,void>'
[build] with
[build] [
[build] R=const godot::Moment &
[build] ]
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/type_info.hpp(104): note: see declaration of 'godot::GetTypeInfo<R,void>'
[build] with
[build] [
[build] R=const godot::Moment &
[build] ]
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/method_bind.hpp(556): note: the template instantiation context (the oldest one first) is
[build] src\godot-extension\MomentsManager.cpp(64): note: see reference to function template instantiation 'godot::MethodBind *godot::ClassDB::bind_method<godot::MethodDefinition,const godot::Moment&(__cdecl godot::MomentsManager::* )(int64_t) const,>(N,M)' being compiled
[build] with
[build] [
[build] N=godot::MethodDefinition,
[build] M=const godot::Moment &(__cdecl godot::MomentsManager::* )(int64_t) const
[build] ]
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/class_db.hpp(293): note: see reference to function template instantiation 'godot::MethodBind *godot::create_method_bind<godot::MomentsManager,const godot::Moment&,int64_t>(R (__cdecl godot::MomentsManager::* )(int64_t) const)' being compiled
[build] with
[build] [
[build] R=const godot::Moment &
[build] ]
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/method_bind.hpp(587): note: see reference to class template instantiation 'godot::MethodBindTRC<godot::MomentsManager,const godot::Moment &,int64_t>' being compiled
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/method_bind.hpp(552): note: while compiling class template member function 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTRC<godot::MomentsManager,const godot::Moment &,int64_t>::get_argument_metadata(int) const'
[build] build\_deps\godot-cpp-src\include\godot_cpp/core/method_bind.hpp(556): error C2065: 'METADATA': undeclared identifier
[build] ninja: build stopped: subcommand failed.
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build visualizer/build --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:02.761
[build] Build finished with exit code 1