About Store Forum Documentation Contact
Donations:
345$/mo



Post Reply 
Error LNK2005
Author Message
joacorock Offline
Member

Post: #1
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
Visit this user's website Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #2
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
Find all posts by this user Quote this message in a reply
joacorock Offline
Member

Post: #3
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
Visit this user's website Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #4
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
Visit this user's website Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #5
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
Find all posts by this user Quote this message in a reply
Post Reply