Linker error:LNK2005

HI,

I am getting a linker error in the case of DEBUG. In the release build, successfully build. This application is a dll and using "Use Standard Windows Libraries" in Use MFC option in project setting.

In a build log following settings are:

Debug Setting:
Linker->Input:
setupapi.lib DelayImp.lib version.lib /NODEFAULTLIB:bufferoverflowu.lib delayimp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Release Setting:
Linker->Input:
setupapi.lib DelayImp.lib version.lib /NODEFAULTLIB:bufferoverflowu.lib delayimp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

*******************Following linker error-Debug************

Linking...

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" ( 2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" ( 3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" ( _U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" ( _V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)

Creating library .\Debug32/HPZidi01.lib and object .\Debug32/HPZidi01.exp

\Test\BUILDSHELF\Debug\Testidi01.dll : fatal error LNK1169: one or more multiply defined symbols found

***********************************End*********************************

Please help me where is the problem

Regards
Piyush









Answer this question

Linker error:LNK2005

  • Deb A

    Hi,

    still I could not resolve the problem. I have a project in VC6.0 and converted to Visual studio 2005 then I am able to build properly in release mode but not in debug mode.

    Now I specify nafxcwd.lib  in "Linker->Ignore specific libary"

    Then getting differnt error:

    test_dbgI386.lib(infsdebug.obj) : error LNK2001: unresolved external symbol __afxForceEXCLUDE
    test_dbgI386.lib(infsdebug.obj) : error LNK2001: unresolved external symbol "unsigned int (__stdcall* ATL::g_pfnGetThreadACP)(void)" ( g_pfnGetThreadACP@ATL@@3P6GIXZA)
    test_dbgI386.lib(infsdebug.obj) : error LNK2019: unresolved external symbol "void __stdcall AfxThrowOleException(long)" ( AfxThrowOleException@@YGXJ@Z) referenced in function "void __stdcall ATL::AtlThrowImpl(long)" ( AtlThrowImpl@ATL@@YGXJ@Z)
    test_dbgI386.lib(infsdebug.obj) : error LNK2019: unresolved external symbol "void __stdcall AfxThrowMemoryException(void)" ( AfxThrowMemoryException@@YGXXZ) referenced in function "void __stdcall ATL::AtlThrowImpl(long)" ( AtlThrowImpl@ATL@@YGXJ@Z)
    test_dbgI386.lib(infsdebug.obj) : error LNK2001: unresolved external symbol "class ATL::CTraceCategory ATL::atlTraceException" ( atlTraceException@ATL@@3VCTraceCategory@1@A)
    test_dbgI386.lib(infsdebug.obj) : error LNK2001: unresolved external symbol "public: static class ATL::CTrace ATL::CTrace::s_trace" ( s_trace@CTrace@ATL@@2V12@A)
    test_dbgI386.lib(infsdebug.obj) : error LNK2019: unresolved external symbol _AtlTraceVA referenced in function "public: void __cdecl ATL::CTrace::TraceV(char const *,int,unsigned long,unsigned int,char const *,char *)const " ( TraceV@CTrace@ATL@@QBAXPBDHKI0PAD@Z)
    test_dbgI386.lib(infsdebug.obj) : error LNK2019: unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" ( AfxThrowInvalidArgException@@YGXXZ) referenced in function "int __cdecl AfxCrtErrorCheck(int)" ( AfxCrtErrorCheck@@YAHH@Z)

     

     

     


  • yneill

    The reason could be that the CRT and and MFC libraries are linked in the wrong order.

    Take a look at the following link for more information:
    http://support.microsoft.com/default.aspx scid=kb;en-us;148652

    Hope this helps!

    Thanks,
      Ayman Shoukry
      VC++ Team



  • Linker error:LNK2005