Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: You receive a linker error message when you build an Itanium architecture-based application


View products that this article applies to.

Symptoms

When you build an Itanium architecture-based application that uses Microsoft Foundation Classes (MFC) headers, you may receive the following linker error message:
libcmtd.lib(dbgnew.obj) : error LNK2005: "void * __cdecl operator new(unsigned __int64,int,char const *,int)" (??2@YAPEAX_KHPEBDH@Z) already defined in nafxcwd.lib(afxmem.obj)

libcmtd.lib(dbgnew.obj) : error LNK2005: "[Entry] void * __cdecl operator new(unsigned __int64,int,char const *,int)" (.??2@YAPEAX_KHPEBDH@Z) already defined in nafxcwd.lib(afxmem.obj)

Q833981.exe : fatal error LNK1169: one or more multiply defined symbols found
When you use the UndName tool on the decorated name ??2@YAPEAX_KHPEBDH@Z, you receive the following output:
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation 1981-2001. All rights reserved.
Undecoration of :- "??2@YAPEAX_KHPEBDH@Z" is :- "void * __ptr64 __cdecl operator new(unsigned __int64,int,char const * __ptr64,int)"

↑ Back to the top


Workaround

To work around this problem, define the operators in your application.
#ifdef _DEBUG

void* operator new[](size_t nSize, LPCSTR lpszFileName, int nLine) {
return ::operator new[](nSize, _NORMAL_BLOCK, lpszFileName, nLine); }

void* operator new[](size_t nSize, int nType, LPCSTR lpszFileName, int nLine) {
return ::operator new(nSize, nType, lpszFileName, nLine);
}

#endif

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


More information

Steps to reproduce the problem

1.Install the Microsoft Platform Software Development Kit (SDK) to obtain the 64-bit compilers. For more information about the Microsoft Platform SDK, visit the following Microsoft Web site:
2.Use the following code to create a new .cpp file. Name the file Q833981.cpp.
#include <afx.h>
#include <fstream.h>

int main()
{
    int * p = new int;
    int *p1 = new int[5];
    ifstream ifs;
}
3.Set a 64-bit build environment by using the Set Environment Variable Tool (Setenv.bat). The Set Environment Variable Tool is included with the Microsoft Platform SDK. For example, at a command prompt, run the following command for your build environment:
Windows Server 2003 64-bit build environment
setenv.bat /SRV64 /DEBUG
Windows XP 64-bit build environment
setenv.bat /XP64 /DEBUG
4.Compile the Q833981.cpp file by using Microsoft C/C++ Complier (Cl.exe). This tool is located in the following folder:
Drive\Program Files\Microsoft SDK\Bin\Win64
To compile the file, run the following command at a command prompt:
cl /MTd Q833981.cpp

↑ Back to the top


Keywords: KB833981, kbcompiler, kbcode, kbsdk, kbbug, kberrmsg

↑ Back to the top

Article Info
Article ID : 833981
Revision : 3
Created on : 7/5/2005
Published on : 7/5/2005
Exists online : False
Views : 507