Solved

error LNK2005:  operator new already defined in LIBCMT.lib

Posted on 2000-04-24
2
1,267 Views
Last Modified: 2013-11-20
I'm trying to compile my static MFC multithreaded app and keep getting the linker error:
-----------------
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMT.lib(new.obj)
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMT.lib(delete.obj)
      Found "public: void * __thiscall
-----------------

I put the linker to verbose and verified it is finding the new operator in both nafxcw.lib and libcmt.lib.

Any ideas how to correct this? work arounds?

BTW-Using MFC and STL, everything static linked.

Cheers,
Todd
0
Comment
Question by:toddmoore
2 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 2746389
You're causing the linker to see the MFC libraries and the standard C libraries in the wrong order. There's dozens of ways to do that, and there are two or three ways to actually fix the problem.

All the fixes (and a good description of the problem) are outlined in the Microsoft KnowledgeBase.  Visit http://search.support.microsoft.com/kb/ to start a search. See the KnowledgeBase article Q148652 for the information specific to your question.

..B ekiM

0
 

Author Comment

by:toddmoore
ID: 2748218
Thanks, I made sure every cpp file included stdafx and it fixed the problem.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question