需要帮助解决C++引擎/框架构建中的链接器错误
Need help solving linker error in C++ engine/framework construction
我来这里是万不得已,因为我需要尽快获得帮助,以完成明天到期的作业。
我正在C++中组装一个简单的引擎来处理节点、纹理/资产加载和状态系统。我想尝试继续编码与资产相关的东西,但为了做到这一点,我需要状态系统正常工作。
应用.h
#pragma once
#include "AppGSMEGameStateManager.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;
};
目前,每当我尝试使用上面看到的指针时,在我的测试状态类和主.cpp中,我都会收到链接器错误。(见下文)
测试状态
.cpp#include "AppGSMETestState.h"
#include "AppGSMEApplication.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(){}
主要
.cpp#include "GLglew.h"
#include "GLglfw.h"
#include <conio.h>
#include "AppGSMEApplication.h"
#include "AppGSMETestState.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:Enginemain.obj
Error 10 error LNK2001: unresolved external symbol "public: class EGameStateManager * __thiscall EApplication::GetGameStateManager(void)" (?GetGameStateManager@EApplication@@QAEPAVEGameStateManager@@XZ) D:EngineETestState.obj
通常我会把链接器错误归结为循环包含,但我已经写下了各种各样的序列图,没有任何东西包含包含它本身的东西。这可能是显而易见的。我真的很有压力。任何帮助将不胜感激。
链接器找不到该函数。你需要实现 GetGameStateManager() 函数
相关文章:
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 如何在构建链接列表时调整头、尾指针
- 在树莓派上用libtorch构建程序时的链接问题
- 未知的 GCC 链接器错误,但已成功构建
- 使用Bazel构建具有不同编译器/链接器选项的C/C++依赖关系
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 如何在 Linux 中构建共享库时使未定义引用的链接器失败
- 链接两个使用 c++ 构建的库_static
- 如何防止 CMake 在构建时(而不是在安装时)为共享库创建符号链接?
- 如何在Windows上链接动态构建的cmake文件
- 使用cmake构建google测试单元测试时出现链接器错误
- 使用 gcc 6 构建 OpenJDK8 时出现链接错误
- 如何在bazel中使用make规则链接库构建
- 使用 pybind11 构建库,链接其他共享库
- 使用 VS2017 构建 OpenSSL 后出现一些链接错误。 " OPENSSL_init_ssl referenced in function _main " ?
- 如何使用由for循环创建的向量向量构建链接列表
- 如何让OCaml链接器标志与C++cmake构建链接
- VisualStudio2013下的Google gRPC(C++)构建.链接错误
- Qt Creator项目无法在Windows上构建(链接器错误)
- Xcode中的c++构建链接器错误