Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm getting a linker error using CString the error is:

error LNK2001: unresolved external symbol "private: static class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > CConfiguration::_campaignFolderPath" (?_campaignFolderPath@CConfiguration@@0V?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@A)

I have a class which is defined as:

class CConfiguration
{
private:
    static CString _campaignFolderPath;

public:
    static void Read();

private:
    CConfiguration(void);
    ~CConfiguration(void);
};

Its Read method is defined as:

void CConfiguration::Read()
{
    CConfigFile configReader(_T("Config.ini"));
    TCHAR temp[1024];

    configReader.GetStringValue(_T("Campaigns"), _T("CampaignsFolderPath"), temp);

    _campaignFolderPath = temp;
}

Any clues as to what is causing the error? I'm using Visual Studio 2008

share|improve this question
up vote 7 down vote accepted

You need to instantiate the string, you're just declaring it as static now. Add:

CString CConfiguration::_campaignFolderPath;

in the implementation file.

share|improve this answer
    
error C2039: 'CString' : is not a member of 'CConfiguration' – akif Oct 2 '09 at 14:56
    
CString CConfiguration::_campaignFolderPath; thanks – akif Oct 2 '09 at 14:57
    
do edit your answer please, i believe its a typo – akif Oct 2 '09 at 14:57
    
@Manzoor: thanks, I swapped the symbols by mistake. :) – unwind Oct 2 '09 at 15:02

Do you have an implementation line like the following somewhere?

CString CConfiguration::_campaignFolderPath;

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.