You receive LNK2005 errors when you compile an ATL executable (.exe) project in Visual C++ (184235)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q184235 SYMPTOMS
When you compile an Active Template Library (ATL) executable (.exe) project
in Developer Studio, the _ATL_MIN_CRT preprocessor symbol allows you to use
some standard C library functions without having to link in the C run-time
library (CRT) startup code. If _ATL_MIN_CRT is defined when you build an
ATL executable with Microsoft Foundation Classes (MFC) support, the linker
returns the following linker errors:
nafxcw.lib(afxmem.obj) : error LNK2005: "void * _cdecl operator
new(unsigned int)" (??2@YAPAXI@Z) already
defined in Stdafx.obj
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in StdAfx.obj
CAUSE
Some C run-time library functions require that you provide the CRT startup
code. Because both the C run-time and MFC libraries contain definitions for
the new and delete operators, there is a conflict for the linker.
RESOLUTION
Remove the _ATL_MIN_CRT preprocessor definition and rebuild the project. To
do this, click Settings on the Project menu. On the C/C++ tab, select
the Preprocessor category, and remove the _ATL_MIN_CRT definition.
STATUS
This behavior is by design.
REFERENCES
For additional information, please see the following articles in the
Microsoft Knowledge Base:
173974 HOWTO: Add MFC Support to an ATL Project
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Mark Hagen, Microsoft Corporation.
Modification Type: | Major | Last Reviewed: | 6/6/2005 |
---|
Keywords: | kbtshoot kberrmsg kbprb KB184235 kbAudDeveloper |
---|
|