Jump to content
  • Advertisement
Sign in to follow this  
assainator

linker problem: LNK 2005

This topic is 3319 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
Quote:
main.cpp includes: collision.cpp.

Do you means this or is this just a typo?

Quote:
i get the following error:

Are you using inclusion guards?
Have a look at this article.

Share this post


Link to post
Share on other sites
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
also try not to include the source file instead include the header not the .cpp file but the .h 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!