Common Errors in VC ++: 17:1> nafxcwd. Lib (afxmem. OBJ): Error lnk2005
(1) Error case: When writing logsProgramThe project is an MFC Program (Note: The Win32 console application will not encounter this error, of course, it does not support the MFC library)
(2) Cause of the error: The following figure shows the cause of the error, which is redefined. When you use ***. OBJ, it is already defined in the ***. Lib library.
Excerpt:
I searched the internet for a conflict between the CRT Library and the MFC Library. The solution is: let the program first link nafxcwd. Lib, and then link libcmtd. Lib.
You 've got to change the order inwhich the libraries are linked. This is a bit tricky, since the library are linked automatically, without you explicitly specifying them.
So, first step, tell the linker to ignore the implicit libraries: Project/setting/linker, input tab, and put "nafxcwd. lib libcmtd. lib "in the" libraries to ignore "box.
Next, on the same page, in the object/library modules box, put the same to libraries. (In you still get the same error, try reversing them on this line)
The error message shows that the operators new, delete, delete [] are already in libcmtd. it is defined in Lib, which is related to the link sequence of the default library used during C compilation and the default library used during MFC runtime, we can manually change the compilation sequence of the two databases to solve this definition conflict problem.
(3) site error:
1> link...
1> nafxcwd. lib (afxmem. OBJ): Error lnk2005: "Void * _ cdecl operator new (unsigned INT)" () already in libcmtd. lib (New. OBJ ).
1> nafxcwd. Lib (afxmem. OBJ): Error lnk2005: "Void _ cdecl operator Delete (void *)" () has been defined in libcmtd. Lib (dbgdel. OBJ)
1> nafxcwd. lib (afxmem. OBJ): Error lnk2005: "Void * _ cdecl operator new [] (unsigned INT)" () already in libcpmtd. lib (newaop. OBJ ).
1> nafxcwd. Lib (afxmem. OBJ): Error lnk2005: "Void _ cdecl operator Delete [] (void *)" () has been defined in libcmtd. Lib (delete2.obj)
1> C: \ Documents and Settings \ Administrator \ Desktop \ multithreading write log how to write \ write log 1 \ debug \ write log 1.exe: Fatal error lnk1169: Find one or more symbols with multiple definitions
(4) solution to the error:
Chinese
Project -- Property --- connector --- Input
Additional dependency space nafxcwd. Lib libcmtd. Lib
Ignore specified library space nafxcwd. Lib libcmtd. Lib
Clear the project. Recompile. Done