Linker error LNK2005 ???? 
Author Message
 Linker error LNK2005 ????

Dear Reader,

I have two CPP files:
- ProductSet.cpp (implementation of the class CProductSet)
- Application.cpp

In both files I include the headerfile "ProductSet.h" (Definition of
CProductSet). In the headerfile "ProductSet.h" I include "Values.h".

Now the compiler generates the link error LNK2005 and says that the
functions of the class in Values.h are already defined in the
ProductSet.cpp????

How can I solve this problem?

Thank you,

Johan Machielse



Fri, 19 Mar 2004 20:51:38 GMT  
 Linker error LNK2005 ????
You need to use the #define statement to prevent the
header to be included twice. Define something that
identify your code at the header file, like this:

#ifndef _VALUESH_DEFINED
 #define _VALUESH_DEFINED

// here  goes all the stuff of your values.h file

#endif

hope this information helps

MRitter

Quote:
>-----Original Message-----
>Dear Reader,

>I have two CPP files:
>- ProductSet.cpp (implementation of the class CProductSet)
>- Application.cpp

>In both files I include the headerfile "ProductSet.h"
(Definition of
>CProductSet). In the headerfile "ProductSet.h" I
include "Values.h".

>Now the compiler generates the link error LNK2005 and
says that the
>functions of the class in Values.h are already defined in
the
>ProductSet.cpp????

>How can I solve this problem?

>Thank you,

>Johan Machielse

>.



Sat, 20 Mar 2004 03:32:12 GMT  
 Linker error LNK2005 ????
In all of your .h files, wrap your text within the following preprocessor
definition:

//Your hearder file
#if !defined (__HearderFileName_H)
#define __HeaderFileName_H
.....          //Your header file text here.
#endif

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. Copyright 2001 Microsoft Corporation. All
rights reserved.



Sat, 20 Mar 2004 16:01:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC 7.0 Linker Error LNK2005, LNK4006, LNK1169 _DllMain@12 already defined in MyDll.obj

2. Linker Error LNK2005

3. using _variant_t rather than _bstr_t causing linker error LNK2005

4. help...Linker error: LNK2005

5. linker error LNK2005

6. LNK2005 linker error

7. Linker Tools Error LNK2005

8. Link Errors : error LNK2005 and LNK2004

9. LNK2005 Errors

10. error LNK2005

11. LNK2005 error

12. LNK2005 Errors

 

 
Powered by phpBB® Forum Software