CString Communication Error

I get a linker error using CString:

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 that is defined as:

class CConfiguration
{
private:
    static CString _campaignFolderPath;

public:
    static void Read();

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

His reading 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 causes the error? I am using Visual Studio 2008

+3
source share
2 answers

You need to instantiate the string, you simply declare it as static. Add:

CString CConfiguration::_campaignFolderPath;

in the implementation file.

+7
source

Do you have an implementation string like the following?

CString CConfiguration :: _ campaignFolderPath;

+3
source

Source: https://habr.com/ru/post/1719105/


All Articles