Article ID: 309801 - Last Review: March 19, 2008 - Revision: 4.0 You may receive an LNK2019 error message when you build a Visual C++ 2005 or Visual C++ .NET application that uses a CString-derived class from a DLL fileThis article was previously published under Q309801 Note Microsoft Visual C++ 2005, Microsoft Visual C++ .NET 2003, and Microsoft Visual C++ .NET 2002 support both the managed code
model that is provided by the Microsoft .NET Framework and the unmanaged native
Microsoft Windows code model. The information in this article applies only to
unmanaged Visual C++ code. On This PageSYMPTOMS When you build a Visual C++ 2005 or Visual C++ .NET application that uses a CString-derived class from a DLL file, you may receive an error message
that is similar to one of the following: Message 1 ClientProject error
LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall
ATL::CStringT<char,class StrTraitMFC<char,class
ATL::ChTraitsCRT<char>>>::CStringT<char,class
StrTraitMFC<char,class ATL::ChTraitsCRT<char>>>(char const *)"
(__imp_??0?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@QAE@PBD@Z)
referenced in function _main ClientProject error LNK2005: "public:
__thiscall ATL::CStringT<char,class StrTraitMFC<char,class
ATL::ChTraitsCRT<char>>>::~CStringT<char,class
StrTraitMFC<char,class ATL::ChTraitsCRT<char>>>(void)"
(??1?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@QAE@XZ) already
defined in Simple.obj ClientProject fatal error LNK1169: one or
more multiply defined symbols found CAUSE This behavior may occur if you use a class derived from CString that is also exported from a DLL. In Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET, the CString class has changed to a template class, as demonstrated by the following lines of code taken from afxstr.h: RESOLUTION To resolve this issue, explicitly import the template class
for CStringT and CSimpleStringT in the precompiled header (stdafx.h) file, as follows: MORE INFORMATIONSteps to Reproduce the Problem
| Article Translations
|
Back to the top
