LNK2005: delete already defined error in VC++

2020-02-16 04:02发布

问题:

I am newbie to VC++, so please forgive me if this is stupid.

I have got 7 solutions under one project. Six of these build static libraries which is linked inside 7th to produce an exe. The runtime configuration of all the projects is MultiThreaded Debug. sln which is used to produce exe is using MFC other slns use standard runtiem library. I tried changing those to MFC, but still I am getting the same error. All the six slns build successfully. When I try to build exe - get the follwoing error:

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *,int,char const *,int)" (??3@YAXPAXHPBDH@Z) already defined in tara_common.lib(fileStream.obj)

This is weird because tara_common is one of the libs that I generated and fileStream.cpp is file that is just using delete on a pointer.

I built it in verbose mod, so I am attaching the output.

ENVIRONMENT SPACE

_ACP_ATLPROV=C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin\ATLProv.dll
    _ACP_INCLUDE=C:\Program Files\Microsoft Visual Studio 9.0\VC\include;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\include
    _ACP_LIB=C:\fta\tara\database\build\Debug;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\i386;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;C:\Program Files\Microsoft Visual Studio 9.0\;C:\Program Files\Microsoft Visual Studio 9.0\lib
    _ACP_PATH=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\tools;C:\Program Files\Microsoft Visual Studio 9.0\Common7\ide;C:\Program Files\HTML Help Workshop;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\;C:\WINDOWS\SysWow64;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\GnuWin32\bin;C:\Python26
    ALLUSERSPROFILE=C:\Documents and Settings\All Users
    CLIENTNAME=Console
    CommonProgramFiles=C:\Program Files\Common Files
    ComSpec=C:\WINDOWS\system32\cmd.exe
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    INCLUDE=C:\Program Files\Microsoft Visual Studio 9.0\VC\include;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\include
    LIB=C:\fta\tara\database\build\Debug;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\i386;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;C:\Program Files\Microsoft Visual Studio 9.0\;C:\Program Files\Microsoft Visual Studio 9.0\lib
    LIBPATH=c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib
    LOGONSERVER=\\xxx
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    PATH=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\Microsoft SDKs\Windows\v6.0A\\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\tools;C:\Program Files\Microsoft Visual Studio 9.0\Common7\ide;C:\Program Files\HTML Help Workshop;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\;C:\WINDOWS\SysWow64;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\GnuWin32\bin;C:\Python26
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=170a
    ProgramFiles=C:\Program Files
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\WINDOWS
    VisualStudioDir=C:\Documents and Settings\sgupta\My Documents\Visual Studio 2008
    VS90COMNTOOLS=C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\
    WecVersionForRosebud.710=2
    windir=C:\WINDOWS

COMMAND LINES:

Creating temporary file "c:\fta\tools\channel_editor\IvoDB\Debug\RSP00011018082288.rsp" with contents
[
/VERBOSE /OUT:"C:\fta\tools\channel_editor\\Builds\IvoDB_1_35_Debug.exe" /INCREMENTAL /LIBPATH:"..\..\..\3rdparty\boost_1_42_0\stage\lib" /MANIFEST /MANIFESTFILE:"Debug\IvoDB_1_35_Debug.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DELAYLOAD:"OleAcc.dll" /DEBUG /PDB:"C:\fta\tools\channel_editor\Builds\IvoDB_1_35_Debug.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 ..\..\..\tara\database\build\Debug\tara_database.lib ..\..\..\tara\common\build\Debug\tara_common.lib ..\..\..\3rdparty\sqliteWrapper\Debug\sqliteWrapper.lib ..\..\..\3rdparty\sqlite_3_6_18\Debug\sqlite.lib ..\..\..\stsdk\modules\win32\Debug\modules.lib ..\..\..\stsdk\axeapi\win32\Debug\axeapi.lib DelayImp.lib

".\Debug\AntennaSettings.obj"

".\Debug\AudioVideoSettings.obj"

".\Debug\CMDatabase.obj"

".\Debug\CMSettings.obj"

".\Debug\ColorFileDialog.obj"

".\Debug\ColorStatic.obj"

".\Debug\DragDropListCtrl.obj"

".\Debug\DragDropTreeCtrl.obj"

".\Debug\FavouriteEdit.obj"

".\Debug\FavTab.obj"

".\Debug\FindProgram.obj"

".\Debug\HyperLink.obj"

".\Debug\IvoDB.obj"

".\Debug\IvoDBDlg.obj"

".\Debug\IvoDBInfo.obj"

".\Debug\IvoDBInfoTab.obj"

".\Debug\IvoDbStruct.obj"

".\Debug\LayoutHelper.obj"

".\Debug\MainTab.obj"

".\Debug\OperTabCtrl.obj"

".\Debug\ParentalLock.obj"

".\Debug\ProgramEdit.obj"

".\Debug\ProgramTab.obj"

".\Debug\PVRSettings.obj"

".\Debug\SatTab.obj"

".\Debug\SettingsBase.obj"

".\Debug\SettingsTab.obj"

".\Debug\STBSettings.obj"

".\Debug\stdafx.obj"

".\Debug\TimeDate.obj"

".\Debug\TransponderEdit.obj"

".\Debug\TreeTab.obj"

".\Debug\UserPreferences.obj"

".\Debug\Xmodem.obj"

".\Debug\IvoDB.res"

".\Debug\IvoDB_1_35_Debug.exe.embed.manifest.res"
]


Creating command line "link.exe @c:\fta\tools\channel_editor\IvoDB\Debug\RSP00011018082288.rsp /NOLOGO /ERRORREPORT:PROMPT"



**Processed /DEFAULTLIB:atlsd.lib
Processed /DEFAULTLIB:ws2_32.lib
Processed /DEFAULTLIB:mswsock.lib
 Processed /DISALLOWLIB:mfc90d.lib
 Processed /DISALLOWLIB:mfcs90d.lib
 Processed /DISALLOWLIB:mfc90.lib
 Processed /DISALLOWLIB:mfcs90.lib
 Processed /DISALLOWLIB:mfc90ud.lib
 Processed /DISALLOWLIB:mfcs90ud.lib
 Processed /DISALLOWLIB:mfc90u.lib
 Processed /DISALLOWLIB:mfcs90u.lib
 Processed /DISALLOWLIB:uafxcwd.lib
 Processed /DISALLOWLIB:uafxcw.lib
 Processed /DISALLOWLIB:nafxcw.lib
      Found "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)
        Referenced in axeapi.lib(ipcgeneric.obj)

        Referenced in axeapi.lib(ipccommon.obj)
        Referenced in axeapi.lib(activeobject.obj)
        Referenced in nafxcwd.lib(nolib.obj)
        Referenced in sqliteWrapper.lib(DbConnection.obj)
        Referenced in sqliteWrapper.lib(Statement.obj)
        Referenced in axeapi.lib(nvstorage.obj)
        Referenced in axeapi.lib(avctrler.obj)
        Referenced in tara_common.lib(trace.obj)
        Referenced in tara_common.lib(ssPrintf.obj)
        Referenced in tara_common.lib(taraConfig.obj)
        Referenced in tara_common.lib(stream.obj)
        Referenced in tara_common.lib(STBConfigurationStorage.obj)
        Referenced in tara_common.lib(STBConfiguration.obj)
        Referenced in tara_common.lib(configParser.obj)
        Referenced in tara_common.lib(fileStream.obj)
        Referenced in tara_database.lib(SatStream.obj)
        Referenced in tara_database.lib(Service.obj)
        Referenced in tara_database.lib(ServiceList.obj)
        Referenced in tara_common.lib(playerConfig.obj)
        Referenced in UserPreferences.obj
        Referenced in Xmodem.obj
        Referenced in tara_database.lib(init.obj)
        Referenced in tara_database.lib(Satellite.obj)
        Referenced in TransponderEdit.obj
        Referenced in TreeTab.obj
        Referenced in TreeTab.obj
        Referenced in UserPreferences.obj
        Referenced in stdafx.obj
        Referenced in TimeDate.obj
        Referenced in TimeDate.obj
        Referenced in TransponderEdit.obj
        Referenced in SettingsTab.obj
        Referenced in SettingsTab.obj
        Referenced in STBSettings.obj
        Referenced in STBSettings.obj
        Referenced in SatTab.obj
        Referenced in SatTab.obj
        Referenced in SettingsBase.obj
        Referenced in SettingsBase.obj
        Referenced in ProgramTab.obj
        Referenced in ProgramTab.obj
        Referenced in PVRSettings.obj
        Referenced in PVRSettings.obj
        Referenced in ParentalLock.obj
        Referenced in ParentalLock.obj
        Referenced in ProgramEdit.obj
        Referenced in ProgramEdit.obj
        Referenced in MainTab.obj
        Referenced in MainTab.obj
        Referenced in OperTabCtrl.obj
        Referenced in OperTabCtrl.obj
        Referenced in IvoDBInfoTab.obj
        Referenced in IvoDbStruct.obj
        Referenced in LayoutHelper.obj
        Referenced in LayoutHelper.obj
        Referenced in IvoDBDlg.obj
        Referenced in IvoDBInfo.obj
        Referenced in IvoDBInfo.obj
        Referenced in IvoDBInfoTab.obj
        Referenced in HyperLink.obj
        Referenced in IvoDB.obj
        Referenced in IvoDB.obj
        Referenced in IvoDBDlg.obj
        Referenced in FavTab.obj
        Referenced in FavTab.obj
        Referenced in FindProgram.obj
        Referenced in FindProgram.obj
        Referenced in DragDropTreeCtrl.obj
        Referenced in DragDropTreeCtrl.obj
        Referenced in FavouriteEdit.obj
        Referenced in FavouriteEdit.obj
        Referenced in ColorFileDialog.obj
        Referenced in ColorStatic.obj
        Referenced in DragDropListCtrl.obj
        Referenced in DragDropListCtrl.obj
        Referenced in CMDatabase.obj
        Referenced in CMDatabase.obj
        Referenced in CMSettings.obj
        Referenced in CMSettings.obj
        Referenced in AntennaSettings.obj
        Referenced in AntennaSettings.obj
        Referenced in AudioVideoSettings.obj
        Referenced in AudioVideoSettings.obj
        Loaded nafxcwd.lib(afxmem.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *,int,char const *,int)" (??3@YAXPAXHPBDH@Z) already defined in tara_common.lib(fileStream.obj)**

Please help me out, I have already wasted 3 days looking on net and trying all the possible solutions I found.

thanks in advance, SG

回答1:

Usually this means that you try to link executables (.EXE and .DLL) which link to different versions of the runtime libraries. (If you link DLLs together or to an EXE file you normally should use the dynamic version of the RTLs.)