joacorock
Member
|
Error LNK2005
I'm getting this error when I try to compile my project, I tried to clean and rebuild and didn't work
Code:
1>c:\program files (x86)\esenthelenginesdk\tutorials\auto.cpp(25): warning C4717: 'Auto::Auto' : recursive on all control paths, function will cause runtime stack overflow
1>Jueguito.obj : error LNK2005: "struct EE::Game::ObjMemx<struct EE::Game::Chr> Chrs" (?Chrs@@3U?$ObjMemx@UChr@Game@EE@@@Game@EE@@A) already defined in Auto.obj
1>Jueguito.obj : error LNK2005: "struct EE::Game::ObjMemx<struct EE::Game::Item> Items" (?Items@@3U?$ObjMemx@UItem@Game@EE@@@Game@EE@@A) already defined in Auto.obj
1>Jueguito.obj : error LNK2005: "struct EE::Game::ObjMemx<struct EE::Game::Static> Statics" (?Statics@@3U?$ObjMemx@UStatic@Game@EE@@@Game@EE@@A) already defined in Auto.obj
|
|
02-05-2012 12:08 AM |
|
fatcoder
Member
|
RE: Error LNK2005
Your header is missing externs.
You need this in the .h
Code:
extern Game::ObjMemx<Game::Static> Statics
And this in the .cpp
Code:
Game::ObjMemx<Game::Static> Statics
Repeat for the others.
|
|
02-05-2012 12:42 AM |
|
joacorock
Member
|
RE: Error LNK2005
It gives me the following error now:
Code:
Auto.cpp
1>c:\program files (x86)\esenthelenginesdk\tutorials\auto.cpp(4): error C2086: 'EE::Game::ObjMemx<TYPE> Statics' : redefinition
1> with
1> [
1> TYPE=EE::Game::Static
1> ]
1> c:\program files (x86)\esenthelenginesdk\tutorials\auto.h(1) : see declaration of 'Statics'
|
|
02-05-2012 12:46 AM |
|
Dynad
Member
|
RE: Error LNK2005
You have included the header more then 1 time so the compiler thinks you're declaring the containers with the same name more then once which is not correct and the compiler will give you a linking error.
There is always evil somewhere, you just have to look for it properly.
|
|
02-05-2012 01:54 AM |
|
Barthap
Member
|
RE: Error LNK2005
in only ONE .cpp: (for example game.cpp)
Code:
Game::ObjMemx<Game::Static> Statics;
in any .h file (wherever you want, main.h for example)
Code:
extern Game::ObjMemx<Game::Static> Statics;
(This post was last modified: 02-06-2012 11:42 AM by Barthap.)
|
|
02-06-2012 11:41 AM |
|