Fix for debug error: Error LNK2005: "void * __cdecl operator new (unsigned int)" (?? 2@YAPAXI@Z) already defined in LIBCMT.lib (new.obj)

Source: Internet
Author: User

Issue: Error LNK2005: "void * __cdecl operator new (unsigned int)" (?? 2@YAPAXI@Z) is already defined in LIBCMT.lib (new.obj).

Reference: http://zhanyonhu.blog.163.com/blog/static/16186044201023094754832/

1>uafxcw.lib (afxmem.obj): Error LNK2005: "void * __cdecl operator new (unsigned int)" (?? 2@YAPAXI@Z) already defined in LIBCMT.lib (new.obj)
1>uafxcw.lib (afxmem.obj): Error LNK2005: "Void __cdecl operator delete (void *)" (?? 3@YAXPAX@Z) already defined in LIBCMT.lib (delete.obj)
1>uafxcw.lib (afxmem.obj): Error LNK2005: "void * __cdecl operator new[] (unsigned int)" (?? _U@YAPAXI@Z) already defined in LIBCMT.lib (new2.obj)
1>, .... /bin/tllogger_unicode_release.exe:fatal Error LNK1169: Find one or more multi-definition symbols

Workaround:

Http://blog.vckbase.com/zaboli/archive/2010/02/05/40921.aspx

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:

Forces the linker to link the library in the correct order.

Project->properties->linker->ignore specific Library add Uafxcwd.lib Libcmtd.lib

Add Uafxcwd.lib Libcmtd.lib in additional dependencied

My Workaround: Project Properties--configuration--General--MFC use: "Static" or "dynamic" link MFC. And then compile, you can do it.

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.