Solved

error LNK2005:  operator new already defined in LIBCMT.lib

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 58
sumDigits challenge 9 120
maven archtype selection in eclipse 1 53
Use of condition with 'serial' in ansible 2 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now