我知道这是一个常见问题,但我很确定我包含文件的方式没有错误。
我会给你基本的文件。
主要.cpp:
#include "GameState.h"
#inlcude "Timer.h"
int main ( int argc, char** argv ) {
游戏状态.h:
#pragma once
#include "Character.h"
字符.h:
#pragma once
#include "Setup.h"
设置.h:
#pragma once
#include "SDL.h"
#include "SDL_main.h"
#include "SDL_image.h"
错误报告:
Error 1 error LNK2005: "void __cdecl apply_surface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?apply_surface@@YAXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) already defined in Character.obj C:\Users\Jim\Documents\C++\herorpg\herorpg\Main.obj
Error 2 error LNK2005: "bool __cdecl init(struct SDL_Surface * &)" (?init@@YA_NAAPAUSDL_Surface@@@Z) already defined in Character.obj C:\Users\Jim\Documents\C++\herorpg\herorpg\Main.obj
Error 3 error LNK2005: "bool __cdecl load_files(struct SDL_Surface * * const)" (?load_files@@YA_NQAPAUSDL_Surface@@@Z) already defined in Character.obj C:\Users\Jim\Documents\C++\herorpg\herorpg\Main.obj
Error 4 error LNK2005: "struct SDL_Surface * __cdecl load_image(char *)" (?load_image@@YAPAUSDL_Surface@@PAD@Z) already defined in Character.obj C:\Users\Jim\Documents\C++\herorpg\herorpg\Main.obj
Error 6 error LNK1169: one or more multiply defined symbols found C:\Users\Jim\Documents\C++\herorpg\Debug\herorpg.exe
我包含的内容有什么问题吗?如果您认为需要更多信息,我将发布完整代码。只是之前觉得很麻烦。