Linker Error: Already Detected

I am trying to compile my Visual C ++ project (uses MFC) in Microsoft Visual Studio 2012, and it returns with the following errors:

error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)   
error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) 
error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)
error LNK1169: one or more multiply defined symbols found

So, I searched the language a bit and found this page: http://support.microsoft.com/?scid=kb%3Ben-us%3B148652&x=13&y=8 I tried one solution, but the “Ignore libraries” checkbox does not exist, but also the Object / Library module. For Ignored libraries, I found Ignore specific libraries, but skipping the fifth step gave me only 17xx errors.

I searched a lot in googled but always came back to the same page, how can I fix this problem in Visual Studio 2012?

+2
source share
5 answers

I fixed the problem: I found that this is a problem with the order of inclusions. However, forcing each file to have afx.h include (properties-> c / C ++ / advanced / force include file) fixed the problem for me.

+2
source

The most likely cause of the problem is that there are different versions of the C runtime (multi-user or single-threaded, debugging or non-debugging) associated with different parts of the project. Your main executable may have one associated runtime, but you are linking to a library built with a different version. Use the depend.exe file to check each library that you explicitly link, in turn, to find the odd one.

+2
source

, , .c( ) MFC. .c ( ), , . , .

, .

+1

, LTGC ( ), operator new - , CRT, , " ". VS 2015.

+1

Visual Studio 2008 2010?

Visual Studio 2012: , , error LNK2005: "void * __cdecl operator new(unsigned __int64,void *)" (??2@YAPEAX_KPEAX@Z) already defined. , MFC.

, , Microsoft. , VS2010, .

( , "" > " " > "" > " " "v110" "v100" . , VS2010 , , VS2012.)

EDITED TO ADD: This error is reported by Microsoft as error # 768788 .

0
source

Source: https://habr.com/ru/post/1681578/


All Articles