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

Started by
2 comments, last by Brennon 20 years, 4 months ago
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...
When your nose starts to bleed, you know its time for a snooze.
Advertisement
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.
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).

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?

This topic is closed to new replies.

Advertisement