Solved

error LNK2005:  operator new already defined in LIBCMT.lib

Posted on 2000-04-24
2
1,210 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
Comment Utility
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
Comment Utility
Thanks, I made sure every cpp file included stdafx and it fixed the problem.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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