+3 votes

I have managed to setup my project with help of https://gamedevadventures.posthaven.com/

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 __getbasetypename, registermethods

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

in Engine by (28 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.