GDNative plugin (Native library) how to return a custom class

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mikekulasinski

I have managed to setup my project with help of

However I got stacked when I linked my c++ code with godot plugin. I can’t find a way to return my custom class to Godot.

class MyClass {


class Simple : public GodotScript<Reference> {
  void say(String message) {
    String hello(String target) {
        return String("Hello you, {0}!").format(Array::make(target));
    MyClass getMyClass() {
      return MyClass();
   static void _register_methods() {
        register_method("say", &Simple::say);
        register_method("hello", &Simple::hello);
        register_method("myClass", &Simple::getMyClass);

extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {

extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {

When i run it i get these error

error: ‘___get_type_name’ is not a member of ‘MyClass’
  godot::nativescript_api->godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);

and many more with ___get_base_type_name, _register_methods

How do I register a custom class with godot plugin? If i replace MyClass with Dictionary for example its not a problem.

Thanks for help

I assume that you must use the Godot base classes, like Object or Node, becuase your class seems to lack a default propertiy.
I howhaver have never acutally worked with GDNative, I’ve only read about it.

coffeeDragon | 2018-06-08 14:11