views:

217

answers:

3

I have a C++ project that has been compiling and linking without problems. Recently we added code to override the global new and delete operators and now the project fails to link with the error: error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined. I have spent a lot of time googling this problem and trying anything that is suggested as well as searching this forum. I am also aware of MS KB148652 and have done what it suggested -- I've placed Nafxcwd.lib and Libcmtd.lib in the Additional Dependencies and Ignore Specific Libary lists. Actually they were already there since I had to add them to eliminate other previous linker errors. I've made sure that the first include in all .cpp files is stdafx.h (as KB148652 suggests) but nothing seems to work. If anyone can suggest another approach or some direction I haven't tried I'd appreciate knowing about it. Thanks in advance.

A: 

Check the post here: http://groups.google.com/group/google-perftools/browse_thread/thread/41cd3710af85e57b. The google chrome browser dev people replaces crt malloc this way and I found it very useful

Long Cheng
A: 

Have you cleaned the whole project and tryed to rebuild it from scratch?

Frank
A: 

in c++ , overloaded operators are not inherited through the class hierarchy, so try to completely redefine a separate copy of new and delete in each derived class without referring to the base class's definition using base_class::operator new,
i hope i could help you

Ala ABUDEEB