• Advertisement
Sign in to follow this  

linker problem: LNK 2005

This topic is 3202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

heey all, i'm having a problem. if i have 3 files: main.cpp collision.cpp collision.h Object.cpp main.cpp includes: collision.cpp. collision.cpp includes: collision.h Object.cpp includes: collision.h i get the following error:
Quote:
Linking... 1>collision.obj : error LNK2005: "public: void __thiscall CollisionQueue::InsertCollisionEvent(struct P2D,int)" (?InsertCollisionEvent@CollisionQueue@@QAEXUP2D@@H@Z) already defined in main.obj 1>collision.obj : error LNK2005: "public: __thiscall CollisionQueue::CollisionQueue(void)" (??0CollisionQueue@@QAE@XZ) already defined in main.obj 1>C:\Users\Lars\Documents\3dtry\C\Walking_3d\Debug\shooter.exe : fatal error LNK1169: one or more multiply defined symbols found
can somebody help me? i've searched a lot but still haven't found a solution. assainator

Share this post


Link to post
Share on other sites
Advertisement
If you dont use header protection that would happen. If you are make sure you are not writing it twice (one in each file).

Share this post


Link to post
Share on other sites
Whether or not he should use include guards is irrelevant to the problem; they don't prevent multiple definitions over different translation units. Problem is implementation files are pulled into several translation units (probably what's going on when he includes cpp-files), and is not solved by include guards. Properly structuring the project, as described by the article linked, do.

Share this post


Link to post
Share on other sites
Quote:
Original post by owiley
also try not to include the source file instead include the header not the .cpp file but the .h file.


thanks that fixed the problem.

assainator

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement