Troubleshooting
Problem
This technote explains why the error might occur when IBM® Rational® Test RealTime™ instruments a Microsoft® Foundation Class (MFC) application. This application uses dynamic link libraries (DLLs) of the Application Framework Extensions (AFX) .
Symptom
During the instrumentation of an MFC application with AFX DLLs the following error occurs at link time.
The full error message is as follows:
error LNK2005: "void * __cdecl operator new(unsigned int)" already defined
Cause
The Target Deployment Port contains a redefinition of the two C++ functions new
and delete. As a consequence the Target Deplyment Port can now detect memory leaks.
By default the Target Deployment Port on Windows tries to link the application statically. This is not possible with applications that use MFC classes and the AFX DLLs, because it results in a double definition of the new operator.
Resolving The Problem
Modify the settings for the runtime analysis node or the component testing for C++ node. Add the following flags:
Configuration Settings > Build > Compiler > Preprocessor Options: -D_AFXDLL -MD
Configuration Settings > Build > Linker > Link Flags: /nodefaultlib:msvcrt
Historical Number
152827401
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21131990