error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC@@UAE@XZ) already de

error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC@@UAE@XZ) already 

uafxcwd.lib(afxglobals.obj) error LNK2005: "public: virtual __thiscall CMemDC::~CMemDC(void)" (??1CMemDC@@UAE@XZ) already defined in bstbtn.obj

It means that I found two definitions, one in uafxcwd.lib (afxglobals.obj) and the other in bstbtn.obj (the inherited CButton class I wrote).

There is a Bstbtn.h file in the project, which defines a CMemDC class. Unfortunately, the MFC of VS2012 has added this class, so there will be problems when linking.

How can it be solved? There are the following methods:

1 Modify the name of CMemDC in MFC, and change the name of CMemDC in Bstbtn

 

Baidu's other methods: (personal test unsuccessful)

Add a macro definition,

#define CMemDC XCMemDC

Add the above statement to the end of stdafx.h. (You can also define macros in the form of compiler commands in the project property page, the format is /D "CMemDC=XCMemDC")

 

 

 

Guess you like

Origin blog.csdn.net/txwtech/article/details/105421128