VC ++读取链接错误输出并修复它 - LNK2019

时间:2016-02-06 21:35:32

标签: c++ dll linker lnk2019

这可能是也可能不是重复,但我发现的并没有帮助。所以我制作了一个DLL,可以轻松地使用SDL2进行OOP。几乎所有的课程都是有效的,除了我刚刚制作的课程,而且在考试中它不起作用。

测试版本的错误日志:

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)

以下是我的文件的基本布局:

测试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

和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 };
}

基本上,这个错误说的是什么,如何阅读并将其与我的代码对应,而不必每次都向你们求助。我的图书馆在测试程序中没有正确链接的错误是什么?

0 个答案:

没有答案