Uafxcwd.lib (afxmem.obj): Error LNK2005 Workaround

Source: Internet
Author: User

The project is non-MFC, but to use the MFC library, the use of problems encountered during the summary of

Uafxcwd.lib (afxmem.obj): Error LNK2005: "void * __cdecl operator new (unsigned int)" ([email protected]@z) already defined In LIBCMTD.lib (new.obj)
Uafxcwd.lib (afxmem.obj): Error LNK2005: "Void __cdecl operator delete (void *)" ([email protected]@z) already defined in L IBCMTD.lib (Dbgdel.obj)
Uafxcwd.lib (afxmem.obj): Error LNK2005: "Void __cdecl operator delete[] (void *)" ([email protected]@z) already defined in LIBCMTD.lib (Delete2.obj)

Reason:
The CRT library uses weak external links to the new, delete, and DllMain functions. The MFC library also contains the new, delete, and DllMain functions. These functions require that you link the MFC library before you link the CRT library.
The following LNK2005 errors may occur when the link order of the C run-time (CRT) library and the Microsoft Foundation Class (MFC) library is incorrect.

Workaround:
Force the linker to link the library in the correct order!
Item, properties, Linker-Type: Additional dependencies add Uafxcwd.lib

Problem Solving!

Note: The Uafxcwd.lib library is a Debug version and the release version is Uafxcw.lib

Reprint: Http://blog.sina.com.cn/s/blog_6f50984a0100y9br.html (this solves the project problem)

Reprint: http://blog.csdn.net/chenyujing1234/article/details/8003413

These two articles are referenced by the settings, according to their own projects to verify

Note: "Error lnk2026:module unsafe for SAFESEH image" will also appear when release.

The solution is:

Reprint: http://blog.sina.com.cn/s/blog_493667730100ywt9.html

Uafxcwd.lib (afxmem.obj): Error LNK2005 Workaround

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.