Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object files linking error

Status
Not open for further replies.

joekibz

Programmer
May 17, 2006
8
KE
Problem:

I have an MFC application .

It compiles OK but whenever i build it i get numerous link errors telling me that the functions defined have already been defined in the .obj files .

What is the problem?
 
numerous link errors: for example?...
 
Sounds like you have code in header files, and have included those header files in several source files (and thus now have multiple copies of the functions).



--
 

Salem's reply :

Sounds like you have code in header files, and have included those header files in several source files (and thus now have multiple copies of the functions).

joekibz:

Yeah , its an MFC dialog application with several child dialogs . There is one main header file which i have included in in most of the dialogs .
Question:
How would you recommend i go about troubleshooting this problem ?

 
Start from the beginning, present examples of diagnostic messages...
 
Does your header file have #ifndef guard statements?
Ex:
Code:
#ifndef MY_WONDERFUL_HEADER_INCLUDED
#define MY_WONDERFUL_HEADER_INCLUDED

// Put all the header stuff here...

#endif // MY_WONDERFUL_HEADER_INCLUDED
 

ArkM here are some of the messages ...

error LNK2005: "struct pcap_if * hegre" (?hegre@@3PAUpcap_if@@A) already defined in ifdef.obj

ifdefDlg.obj : error LNK2005: "struct pcap * diz" (?diz@@3PAUpcap@@A) already defined in ifdef.obj

mehead.obj : error LNK2005: "struct pcap_if * hegre" (?hegre@@3PAUpcap_if@@A) already defined in ifdef.obj

mehead.obj : error LNK2005: "struc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top