Solved

error LNK2005:  operator new already defined in LIBCMT.lib

Posted on 2000-04-24
2
1,357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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