Microsoft KB Archive/833981

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

Article ID: 833981

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Windows Server 2003, Enterprise Edition for Itanium-based Systems
 * Microsoft Windows Server 2003, Datacenter Edition for Itanium-Based Systems
 * Microsoft Windows XP Professional for Itanium-based systems
 * Microsoft Windows XP Professional for Itanium-based systems

-



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: &quot;void * __cdecl operator new(unsigned __int64,int,char const *,int)&quot; (??2@YAPEAX_KHPEBDH@Z) already defined in nafxcwd.lib(afxmem.obj)

libcmtd.lib(dbgnew.obj) : error LNK2005: &quot;[Entry] void * __cdecl operator new(unsigned __int64,int,char const *,int)&quot; (.??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 :- &quot;??2@YAPEAX_KHPEBDH@Z&quot; is :- &quot;void * __ptr64 __cdecl operator new(unsigned __int64,int,char const * __ptr64,int)&quot;



WORKAROUND
To work around this problem, define the operators in your application.
 * 1) 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); }


 * 1) endif



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
 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:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm?p=/msdownload/platformsdk/sdkupdate/home.htm

  Use the following code to create a new .cpp file. Name the file Q833981.cpp.
 * 1) include 
 * 2) include 

int main {   int * p = new int; int *p1 = new int[5]; ifstream ifs; }  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

</li></ul> </li> Compile the Q833981.cpp file by using Microsoft C/C++ Complier (Cl.exe). This tool is located in the following folder:

\Program Files\Microsoft SDK\Bin\Win64

To compile the file, run the following command at a command prompt:

cl /MTd Q833981.cpp

</li></ol>

Additional query words: ia64 mfc LNK2005 sdk libcmtd.lib compiler cl operator

Keywords: kberrmsg kbbug kbsdk kbcode kbcompiler KB833981

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.