I have a Visual Studio 2010 project done on MFC. I receive these errors:
2>COrderContentsItemsDocument.obj : error LNK2028: unresolved token (0A0001CA) "public: static struct CRuntimeClass * __stdcall COrderContentsItem::GetThisClass(void)" (?GetThisClass@COrderContentsItem@@$$FSGPAUCRuntimeClass@@XZ) referenced in function "public: virtual struct CRuntimeClass * __thiscall COrderContentsItemsDocument::GetItemsRuntimeClass(void)" (?GetItemsRuntimeClass@COrderContentsItemsDocument@@$$FUAEPAUCRuntimeClass@@XZ)
2>COrderContentsItemsDocument.obj : error LNK2019: unresolved external symbol "public: static struct CRuntimeClass * __stdcall COrderContentsItem::GetThisClass(void)" (?GetThisClass@COrderContentsItem@@$$FSGPAUCRuntimeClass@@XZ) referenced in function "public: virtual struct CRuntimeClass * __thiscall COrderContentsItemsDocument::GetItemsRuntimeClass(void)" (?GetItemsRuntimeClass@COrderContentsItemsDocument@@$$FUAEPAUCRuntimeClass@@XZ)
2>..\..\Output\Win32\Debug_Unicode\MindSalesManager.exe : fatal error LNK1120: 2 unresolved externals
After some research, I disocovered,that the problem comes when I call
RUNTIME_CLASS(COrderContentsItem)
So, this class is a new one that I copied from another already existing. So I am wondering to discover what is the problem.
Cheers,
Sérgio
The solution is to change the COrderContentsItem.cpp file properties. On solution Explorer, right-click the file, Choose Properties, and in Configration Properties > General change the Item type from “C/C++ header” to “C/C++ compiler”.
May be I did something wrong when creating the file, e. g. choosing .h file instead of .cpp file.