0

This may or may not be a duplication, but what I've found hasn't helped. So I made a DLL to easily do OOP with SDL2. Almost all the classes work except for one that I just made now and in the test it's not working.

The error log from the test build:

LNK2019 unresolved external symbol "public: __thiscallSOE_BasicGUI::Basic_Button::Basic_Button(void)" (??0Basic_Button@SOE_BasicGUI@@QAE@XZ) referenced in function "public: virtual void __thiscall MainApp::makeInstances(void)" (?makeInstances@MainApp@@UAEXXZ)
LNK2019 unresolved external symbol "public: virtual __thiscall SOE_BasicGUI::Basic_Button::~Basic_Button(void)" (??1Basic_Button@SOE_BasicGUI@@UAE@XZ) referenced in function "public: virtual void __thiscall MainApp::makeInstances(void)" (?makeInstances@MainApp@@UAEXXZ)
LNK2019 unresolved external symbol "public: virtual void __thiscall SOE_BasicGUI::Basic_Button::setButtonRect(int,int,int,int)" (?setButtonRect@Basic_Button@SOE_BasicGUI@@UAEXHHHH@Z) referenced in function "public: virtual void __thiscall MainApp::makeInstances(void)" (?makeInstances@MainApp@@UAEXXZ)

Here is the basic layout of my files:

Test program.cpp:

#include "SOE_MainApp.h"
#include "SOE_BasicGUI.h"

class MainApp : public SOE_MainApp {
public:
    MainApp(char* title, int width, int height) : SOE_MainApp(title, width, height) {}
    void makeInstances() {
        SOE_BasicGUI::Basic_Button btn1;
        btn1.setButtonRect(0, 0, 100, 100);
    }
};

int main(int argc, char* argv[]) {
    MainApp app("Save The People", 640, 480);

    return 0;
}

SOE_BasicGUI.h:

#ifndef __SOE_BASICGUI_H__
#define __SOE_BASICGUI_H__

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

#include "SDL.h"
#include "SOE_Object.h"
#include "SOE_Globals.h"
#include "SOE_TextDrawer.h"

class DLL_EXPORT SOE_BasicGUI {
public:
    SOE_BasicGUI();
    ~SOE_BasicGUI();

    struct Basic_Button : public SOE_Object {
        Basic_Button();
        ~Basic_Button();

        virtual void setButtonRect(int x, int y, int w, int h);

        protected:
            SDL_Surface* sprite;
            SDL_Rect buttonBounds;
    };
}

#endif

And SOE_BasicGUI.cpp:

#include "SOE_BasicGUI.h"

SOE_BasicGUI::SOE_BasicGUI() {}

SOE_BasicGUI::~SOE_BasicGUI() {}

SOE_BasicGUI::Basic_Button::Basic_Button() {
    sprite = SDL_CreateRGBSurface(0, 0, 0, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
}

SOE_BasicGUI::Basic_Button::~Basic_Button() {
    SDL_FreeSurface(sprite);
}

void SOE_BasicGUI::Basic_Button::setButtonRect(int x, int y, int w, int h) {
    buttonBounds = { x, y, w, h };
}

So basically, what is this error saying and how do I read it and correspond it to my code without having to ask you guys for help every time. And what's wrong with my library that isn't making it link correctly in the test program?

MPenate
  • 85
  • 1
  • 6

0 Answers0