链接错误CString
我使用 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)
我有一个类,其定义为:
class CConfiguration
{
private:
static CString _campaignFolderPath;
public:
static void Read();
private:
CConfiguration(void);
~CConfiguration(void);
};
其 Read 方法定义为:
void CConfiguration::Read()
{
CConfigFile configReader(_T("Config.ini"));
TCHAR temp[1024];
configReader.GetStringValue(_T("Campaigns"), _T("CampaignsFolderPath"), temp);
_campaignFolderPath = temp;
}
有关导致错误的原因的任何线索吗?我正在使用 Visual Studio 2008
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要实例化该字符串,现在只需将其声明为静态即可。添加:
在实现文件中。
You need to instantiate the string, you're just declaring it as static now. Add:
in the implementation file.
您是否有类似以下的实施线?
CString CConfiguration::_campaignFolderPath;
Do you have an implementation line like the following somewhere?
CString CConfiguration::_campaignFolderPath;