Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link error CString

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

like image 703
akif Avatar asked Oct 28 '25 08:10

akif


1 Answers

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

CString CConfiguration::_campaignFolderPath;

in the implementation file.

like image 62
unwind Avatar answered Oct 29 '25 21:10

unwind



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!