link error
Hi everybody.
I''ve started to make a new game project, and I encountered a problem.
I have a WinMain a couple of classes and file general.h.
general.h is a file with several globals and several functions:
open error, file close it and write to it.
My question is how do I make my class know this file “general.h”.
I tried to include it from every file on my project including the files stdafx.cpp And stdafx.h. (which vc6 added and I don’t know their purpose.) but I always get this annoying error :
Sheep.obj : error LNK2005: "int __cdecl Open_Error_File(char *)" (?Open_Error_File@@YAHPAD@Z) already defined in Game.obj
Sheep.obj : error LNK2005: "int __cdecl Close_Error_File(void)" (?Close_Error_File@@YAHXZ) already defined in Game.obj
Sheep.obj : error LNK2005: "int __cdecl Write_Error(char *,...)" (?Write_Error@@YAHPADZZ) already defined in Game.obj
Sheep.obj : error LNK2005: "struct _iobuf * fp_error" (?fp_error@@3PAU_iobuf@@A) already defined in Game.obj
Debug/SheepInSpace2.exe : fatal error LNK1169: one or more multiply defined symbols found
Wont you Plz plz help me, help meeee.
0 error(s), 0 warning(s)
I think the problem here is that you have the function definitions in general.h and because you''re including it more than once, the functions are being defined multiple times. What I would do is make a file general.cpp which actually implements these functions and make sure that general.h contains only the declarations.
For example
Andy.
For example
// general.h// declarationsint Open_Error_File(char*);int Close_Error_File();int Write_Error(char*,...);
// general.cpp// definitionsint Open_Error_File(char* filename){ // blah blah}int Close_Error_File(){ // blah blah}int Write_Error_(char* string,...){ // blah blah}
Andy.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement