Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error LNK2001: unresolved external symbol "class CCdxUAttSpecs * m_pUAS" (?m_pUAS@@3PAVCCdxUAttSpecs@@A)

in cdxuatts.h, I have the following code:
C#
public:
    void FixSize(char *, int);


in cdxuattspecs.h, I have the following code:
C#
public:
	int		GetAndSetSpecs(int, char *);
	CString		m_szHelp;


in cdxuattqr.cpp I have the following code:

C#
#include "CdxUAtts.h"
#include "CdxUAttSpecs.h"

extern  CCdxUAttSpecs   *m_pUAS;    // <--- why unresolved???
extern  CCdxUAtts       *m_pUA;
.
.
.
   m_pUA->FixSize(name, 16);
.
.
.
   if(m_pUAS->GetAndSetSpecs(1, text))
      m_szUAQRHelp = m_pUAS->m_szHelp;
.
.
.


Can this be related to the fact that GetAndSetSpecs is an "int" while FixSize is "void"?

Prior to adding the code referencing CCdxUAttSpecs, the code that referenced CCdxUAtts compiled, linked and executed just fine. I fully expected the same to happen with CCdxUAttSpecs but for some reason, I get a link error.
Posted
Comments
tom_delorenzo 24-Sep-12 13:47pm    
Although it appeared as if neither were defined (and since one worked why shouldn't they both work), in actuality, m_pUA was defined in another routine. Thank you.

1 solution

The reference to the variable m_pUAS is unresolved because you never defined it.
In one source code (that is .cpp)) you have to define m_pUAS, e.g.
C++
CCdxUAttSpecs   *m_pUAS = NULL;
 
Share this answer
 
Comments
Chuck O'Toole 24-Sep-12 13:46pm    
In addition to CPallini's excellent response, you've "declared" m_pUAS to be external to your code. OK, but that doesn't "define" the instance of the variable. "extern" only declares an attribute of the variable not the instance of it.
Sergey Alexandrovich Kryukov 24-Sep-12 17:07pm    
Exactly. Good point: this is even more essential bug than not declaring at all, as this is a big misconception. You got it right -- a 5. :-)
--SA
Sergey Alexandrovich Kryukov 24-Sep-12 17:05pm    
Of course. Definitions in, garbage out... :-)
My 5,
--SA
CPallini 25-Sep-12 3:08am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900