0 votes

I'm creating a game with C++ and Godot but when i'm building the DLL with Visual Studio 2019 i get this error:

error LNK2019: símbolo externo "public: __cdecl godot::Player::Player(void)" ([email protected]@@[email protected]) sin resolver al que se hace referencia en la función "void * __cdecl godot::_godot_class_instance_func<class godot::Player>(void *,void *)" ([email protected]@[email protected]@@[email protected]@[email protected])

I tried many things for solve this problem but i cannot fix it, Here is all my project files.

Player.h:

    #pragma once

    #include <core/Godot.hpp>
    #include <gen/KinematicBody2D.hpp>

    using namespace godot;

    namespace godot
    {
        class Player : public KinematicBody2D
        {
        private:
            GODOT_CLASS(Player, KinematicBody2D)

        public:
            static void _register_methods();
            void _init();
            void _process(float delta);
            Player();
            ~Player();
        };
    }

Player.cpp:

#include "Player.h"

void Player::_register_methods()
{
    register_method((char*)"_process", &Player::_process);
}

void Player::_init()
{

}

void Player::_process(float delta)
{

}

GodotLibrary.cpp:

#include "Player.h"

using namespace godot;

extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options * o)
{
    Godot::gdnative_init(o);
}

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options * o)
{
    Godot::gdnative_terminate(o);
}

extern "C" void GDN_EXPORT godot_nativescript_init(void* handle)
{
    Godot::nativescript_init(handle);
    register_class<Player>();
}
in Engine by (64 points)

1 Answer

+1 vote
Best answer

You have constructor and destructor defined in the Player.h but not implemented. Change Player(); and ~Player(); to ~Player() {}; and ~Player() {};

by (360 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.