**编辑,这是我的链接内容的图片......:**
所以,我一直得到“无法解决的外部”错误,我无法修复。 我在不同的网站上阅读了很多关于这个的不同帖子,他们都没有帮助。仍然不知道该怎么做。
有人告诉我一些关于定义和声明变量的事情,但我不明白他的意思......
如果有人可以告诉我在我的代码中修改什么,那会很棒。 :)
错误列表:
Error 5 error LNK1120: 3 unresolved externals C:\Users\MyName\Desktop\SDL_Game\Debug\SDL_Game.exe 1 1 SDL_Game
Error 3 error LNK2001: unresolved external symbol "public: static bool CoreEngine::isRunning" (?isRunning@CoreEngine@@2_NA) C:\Users\MyName\Desktop\SDL_Game\SDL_Game\CoreEngine.obj SDL_Game
Error 2 error LNK2019: unresolved external symbol "public: class Window __thiscall CoreEngine::window(void)" (?window@CoreEngine@@QAE?AVWindow@@XZ) referenced in function "public: __thiscall CoreEngine::CoreEngine(void)" (??0CoreEngine@@QAE@XZ) C:\Users\MyName\Desktop\SDL_Game\SDL_Game\CoreEngine.obj SDL_Game
Error 4 error LNK2019: unresolved external symbol _SDL_main referenced in function _main C:\Users\MyName\Desktop\SDL_Game\SDL_Game\SDL2main.lib(SDL_windows_main.obj) SDL_Game
所有项目文件:
CoreEngine.h
#pragma once
#include <SDL.h>
#include "Window.h"
class CoreEngine
{
public:
Window window();
CoreEngine();
~CoreEngine();
static bool isRunning;
private:
};
CoreEngine.cpp
#include "CoreEngine.h"
#include <iostream>
CoreEngine::CoreEngine()
{
CoreEngine::isRunning = false;
CoreEngine::window;
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
CoreEngine::isRunning = false;
std::cout << "Failed To Initialize SDL" << std::endl;
system("PAUSE");
SDL_Quit();
}
else
{
while (CoreEngine::isRunning)
{
}
}
}
CoreEngine::~CoreEngine()
{
}
window.h中
#pragma once
#include <SDL.h>
class Window
{
public:
Window();
~Window();
SDL_Window* window;
private:
int CreateWindow();
};
Window.cpp
#include "Window.h"
Window::Window()
{
CreateWindow();
}
Window::~Window()
{
}
int Window::CreateWindow()
{
window = SDL_CreateWindow("Engine Title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);
if (window == NULL)
{
return -1;
}
else
{
return 0;
}
}