-
March 24th, 2016, 01:36 AM
#1
error LNK2001: unresolved external symbol
i am using singulton pattern and visual studio 2010. getting this linker error.
error LNK2001: unresolved external symbol "public: static class CAIUInterface * __cdecl CAIUInterface::GetInstance(void)" (? GetInstance@CAIUInterface@@SAPAV1@XZ) D:\15008_CPDS\CPDS\Transmitter.obj CPDS
// this is header file.
class CAIUInterface
{
private:
static bool m_bInstanceFlag; the status of single instance creation.
static CAIUInterface *m_objAIU;
}
// here is function definition.
CAIUInterface* CAIUInterface::GetInstance()
{
///Step1: Check whether instance is created
if (!m_bInstanceFlag)
{
///Step2: If instance is not created, create it newly and update the instance status to true.
m_objAIU = new CAIUInterface();
m_bInstanceFlag = true;
}
///Step3: Return the pointer object or address of CAIUInterface instance.
return m_objAIU;
}
//i am using like following.
int CAppAIUInterface::CloseApp()
{
siResult = CAIUInterface::GetInstance()->Close();
}
-
March 24th, 2016, 03:22 AM
#2
Re: error LNK2001: unresolved external symbol
I do not see where you declare this CAIUInterface::GetInstance() as static.
Victor Nijegorodov
-
March 24th, 2016, 03:49 AM
#3
Re: error LNK2001: unresolved external symbol
Originally Posted by VictorN
I do not see where you declare this CAIUInterface::GetInstance() as static.
//here are header file details
class CAIUInterface
{
private:
static bool m_bInstanceFlag;
static CAIUInterface *m_objAIU;
protected:
CAIUInterface();
public:
std::function<void(unsigned long)> m_fnRx1Handler;
std::function<void(unsigned long)> m_fnRx2Handler;
~CAIUInterface();
static CAIUInterface* GetInstance();
void Printmsg(unsigned long pData);
};
-
March 29th, 2016, 08:04 PM
#4
Re: error LNK2001: unresolved external symbol
And where in cpp you defined those static variables? You only declared in header and not defined them anywhere, that's why the linker is complaining, since it can not find definiton for those static member variables.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|