Recently, I have encountered a very annoying error in VC 6.0 programming. The following error occurs: linking... nafxcwd. Lib (afxmem. OBJ): Error lnk2005: "Void * _ cdecl operator new (unsigned INT )"(?? 2 @ yapaxi @ Z) already defined in libcmtd. Lib (New. OBJ) nafxcwd. Lib (afxmem. OBJ ):
Error lnk2005: "Void _ cdecl operator Delete (void *)"(?? 3 @ yaxpax @ Z) already defined in libcmtd. Lib (dbgdel. OBJ) debug/dcap.exe:
Fatal error lnk1169: one or more multiply defined symbols found
This error is obviously because two libraries linked to provide a function with the same name. However, ignore cannot directly drop libcmtd. Lib because it is a C library. This problem occurs because the library of MFC conflicts with the library of C, and the link sequence must be set, that is, nafxcwd. lib and libcmtd. Lib. But both of them are default libraries, so how do you set their order? I found a solution that is actually tricky: first ignore them, and then add them.
Method:
Project-> settings in the displayed dialog box, select the link tab, select the input option from the drop-down menu of The Link tab, and enter: nafxcwd in the ignore libraries field on the Link tab. lib libcmtd. lib, and then enter: nafxcwd in the object/library modules of the Same tab. lib libcmtd. lib. Click the OK button, and then the order of adding them becomes the order we forced to set.