Archived

This topic is now archived and is closed to further replies.

error LNK2005 !! what the F@&K!!!!

This topic is 5110 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

Hello, Please assist me in not throwing my machine out the window as it is clearly wrong!!! My problem.. I have 1 header file... named FOO1 with a class FOOBAR I have 2 source files... named BAR1 & BAR2.. I have included the header in both source files I have declared a pointer object of the class in BAR1 as in FOOBAR * foo; In BAR2 i have an extern as in extern FOOBAR * foo; The link error i get is the following.. BAR2.OBJ : error LNK2005: "public: void __thiscall FOOBAR::Get_POS_TANK_SPOT(int &,int &)" (?Get_POS_TANK_SPOT@FOOBAR@@QAEXAAH0@Z) already defined in BAR1.obj I am stumped.. have tried everything... anyone come across the problem before?? Thank you if you take the time to help me...

Share this post


Link to post
Share on other sites
Looks like the problem of cyclic dependancies. Try adding:

#ifndef _FOO1_H
#define _FOO1_H

to the start of the header and:

#endif

to the end.

Share this post


Link to post
Share on other sites
quote:
Original post by od1n
Looks like the problem of cyclic dependancies.


Actually, it''s because he defined the member function twice.

Make sure you don''t have the function defined in both of the source files, and if you put the definition in the header file, make sure it''s inline (or else move it out of the header into one of the source files).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Brennon
Please assist me in not throwing my machine out the window as it is clearly wrong!!!



Well, if you know best, shouldn''t you know what the problem is and how to solve it?

Share this post


Link to post
Share on other sites