Solved

error LNK2005:  operator new already defined in LIBCMT.lib

Posted on 2000-04-24
2
1,295 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 139
no14 challenge 14 74
Way to decrease size of apk file 9 112
Problem to Office 1 47
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

697 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