VC ++ general error 1> nafxcwd. Lib (afxmem. OBJ)

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.