我来这里是最后的选择,因为我需要尽快完成这项任务,以便明天完成任务。
我正在用C ++编写一个简单的引擎,该引擎处理节点,纹理/资产加载和状态系统。我想尝试继续编写与资产相关的内容,但是要做到这一点,我需要状态系统在工作。
APPLICATION.h
#pragma once
#include "AppGSM\EGameStateManager.h"
class EGameStateManager;
class EApplication
{
public:
static void Init();
static void RunApp();
EGameStateManager* GetGameStateManager();
protected:
static int windowWidth;
static int windowHeight;
static bool fullScreen;
static bool frameSync;
static char* windowTitle;
};
目前,每当我尝试使用上面显示的指针(在teststate类和main.cpp中)到游戏状态管理器时,都会收到链接器错误。 (见下文)
测试状态
#include "AppGSM\ETestState.h"
#include "AppGSM\EApplication.h"
#include <iostream>
ETestState::ETestState(EApplication* pApp){}
ETestState::~ETestState(){}
void ETestState::Update(float deltaTime)
{
//if(INPUT::GetKey(KEY_T))
//{
// cout << "Entered Test State" << endl;
//}
m_testTimer += deltaTime;
if(m_testTimer > 3.0f)
{
m_pApp->GetGameStateManager()->ChangeState("Second TEST");
}
}
void ETestState::Draw(){}
MAIN.cpp
#include "GL\glew.h"
#include "GL\glfw.h"
#include <conio.h>
#include "AppGSM\EApplication.h"
#include "AppGSM\ETestState.h"
void main()
{
EApplication::Init();
EApplication* pApp = new EApplication();
pApp->GetGameStateManager()->SetState("TEST", new ETestState(pApp));
EApplication::RunApp();
}
这是基本的游戏状态类,其中包含teststate中使用的应用程序指针:
BASEGAMESTATE.h
#pragma once
class EApplication;
class EGameStateManager;
class EBaseGameState
{
public:
EBaseGameState(){}
EBaseGameState(EApplication* pApp);
//always make the destructor virtual !!
virtual ~EBaseGameState();
//all game states must define update and draw
virtual void Update(float deltaTime) = 0;
virtual void Draw() = 0;
protected:
EApplication* m_pApp;
};
这些是链接器错误:
Error 9 error LNK2019: unresolved external symbol "public: class EGameStateManager * __thiscall EApplication::GetGameStateManager(void)" (?GetGameStateManager@EApplication@@QAEPAVEGameStateManager@@XZ) referenced in function _main D:\Engine\main.obj
Error 10 error LNK2001: unresolved external symbol "public: class EGameStateManager * __thiscall EApplication::GetGameStateManager(void)" (?GetGameStateManager@EApplication@@QAEPAVEGameStateManager@@XZ) D:\Engine\ETestState.obj
通常,我会将链接器错误归结为周期性包含,但我写下了排序的顺序图,没有包含任何包含其自身的内容。它可能很明显..我真的很强调。任何帮助将非常感激。
最佳答案
链接器找不到功能。您需要实现GetGameStateManager()函数
关于c++ - 需要帮助解决C++引擎/框架构造中的链接器错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19615279/