C++ 需要帮助解决C+中的链接器错误吗+;引擎/框架结构
我来这里是万不得已的,因为我需要帮助尽快完成明天到期的任务 我在C++中组装了一个简单的引擎,它处理节点、纹理/资产加载和状态系统。我想尝试并继续编写与资产相关的东西,但为了做到这一点,我需要状态系统工作 应用程序.hC++ 需要帮助解决C+中的链接器错误吗+;引擎/框架结构,c++,linker-errors,C++,Linker Errors,我来这里是万不得已的,因为我需要帮助尽快完成明天到期的任务 我在C++中组装了一个简单的引擎,它处理节点、纹理/资产加载和状态系统。我想尝试并继续编写与资产相关的东西,但为了做到这一点,我需要状态系统工作 应用程序.h #pragma once #include "AppGSM\EGameStateManager.h" class EGameStateManager; class EApplication { public: static void Init(); sta
#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;
};
#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;
};
目前,每当我尝试使用上面看到的指向游戏状态管理器的指针时,无论是在我的teststate类还是main.cpp中,我都会收到链接器错误。(见下文)
测试状态.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(){}
#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();
}
以下是链接器错误:
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()函数当然可以。现在我很困惑,我需要返回一个EGameStateManager指针,但我不确定要使函数正确执行,我需要返回哪一个指针。看起来您正在尝试执行类似于singleton
EGameStateManager*EApplication::GetGameStateManager()的操作{static EGameStateManager*gsm=new EGameStateManager();返回gsm;}