所以我一直在尝试修复游戏引擎 SDK 中的一个奇怪错误,该错误使用 Windows 加载光标而不是游戏自己的光标。 解决方法在这里:http://www.crydev.net/wiki/index.php/Use_Custom_Cursor#Step_1:_Fixing_The_Cursor_Bug .
我已按照修复程序进行操作,但在构建游戏 DLL 时我不断收到这些信息:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall MODCursor::MODCursor(void)" (??0MODCursor@@QAE@XZ) referenced in function "public: __thiscall CGame::CGame(void)" (??0CGame@@QAE@XZ) C:\Users\User\Desktop\Crytek\Mods\CryEngine2\Code\Game.obj GameDll
Error 2 error LNK2019: unresolved external symbol "public: __thiscall MODCursor::~MODCursor(void)" (??1MODCursor@@QAE@XZ) referenced in function "public: virtual __thiscall CGame::~CGame(void)" (??1CGame@@UAE@XZ) C:\Users\User\Desktop\Crytek\Mods\CryEngine2\Code\Game.obj GameDll
是的,通常我可以通过正确定义类来很容易地解决这个问题,但在这种情况下它不起作用。我做错了什么?
文件与修复指南中的一样,因此将文件发布到此处没有任何意义,因为它们会浪费空间。如果确实需要这些文件来调查此问题,如果有人需要,我会上传它们。
也许修复本身有错误?与我的构建修复程序的一个可能区别是修复程序使用的是 Visual Studio 2008,而我使用的是 Visual Studio 2013。
最佳答案
也许尝试将其全部放入 .h 文件中:
#ifndef _MOD_CURSOR
#define _MOD_CURSOR
#include <windows.h>
#include "resource.h"
#undef GetUserName // This is a macro in windows.h, gives issues with GetUserName() of ISystem
class MODCursor : public ISystemEventListener
{
public:
MODCursor() {
gEnv->pSystem->GetISystemEventDispatcher()->RegisterListener(this);
m_cursor = LoadCursor((HINSTANCE)g_hInst, MAKEINTRESOURCE(IDC_CURSOR1));
SetCursor(m_cursor);
}
~MODCursor(){
gEnv->pSystem->GetISystemEventDispatcher()->RemoveListener(this);
}
private:
virtual void OnSystemEvent( ESystemEvent event,UINT_PTR wparam,UINT_PTR lparam ) {
if(event == ESYSTEM_EVENT_TOGGLE_FULLSCREEN || event == ESYSTEM_EVENT_RESIZE || event == ESYSTEM_EVENT_CHANGE_FOCUS){
if (m_cursor != GetCursor())
SetCursor(m_cursor);
}
}
HCURSOR m_cursor;
};
#endif
关于c++ - Unresolved external symbol - 指南中有错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21816794/