error LNK2005:XXXX already defined in XXX.lib

 Linking...
base64.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
Searching libraries
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/msvcrtd.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/libcmtd.lib:
Searching ../Output/Debug/USBInfo.lib:
Searching ../../Library Source Code/xerces/lib/xerces-c_2D.lib:
Searching ../../Library Source Code/lib/u3dapi10.lib:
Searching ../../Library Source Code/lib/libeay32.lib:
Searching ../../Library Source Code/lib/libcurl.lib:
Searching ../../Librar~1/lib/Zlib.lib:
Searching F:/New MicrosoftSDK/Lib/ws2_32.lib:
Searching ../Output/Debug/FPHelper.lib:
Searching ../../Debug/CryptoInterface/CryptoInterface.lib:
Searching ../../Debug/FBCommonDLL/FBCommonDll.lib:
Searching F:/New MicrosoftSDK/Lib/Netapi32.lib:
Searching F:/New MicrosoftSDK/Lib/psapi.lib:
Searching F:/New MicrosoftSDK/Lib/Mpr.lib:
Searching F:/New MicrosoftSDK/Lib/Wininet.lib:
Searching F:/New MicrosoftSDK/Lib/version.lib:
Searching F:/New MicrosoftSDK/Lib/Pdh.lib:
Searching ../Output/Debug/DeviceInfo.lib:
Searching F:/New MicrosoftSDK/Lib/setupapi.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/OLDNAMES.lib:
Searching F:/New MicrosoftSDK/Lib/uuid.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/msvcprtd.lib:
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in USBInfo.lib(USBInfo.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator=(class std::basic_string,class std::allocator > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string,class std::allocator >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(class std::basic_string,class std::allocator > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Container_base::~_Container_base(void)" (??1_Container_base@std@@QAE@XZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "bool __cdecl std::operator<,class std::allocator >(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &)" (??$?MDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::_Container_base::_Orphan_all(void)const " (?_Orphan_all@_Container_base@std@@QBEXXZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Container_base::_Container_base(void)" (??0_Container_base@std@@QAE@XZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string,class std::allocator >::length(void)const " (?length@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > __thiscall std::basic_string,class std::allocator >::substr(unsigned int,unsigned int)const " (?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string,class std::allocator >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(char const *)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBD@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::allocator::allocator(void)" (??0?$allocator@D@std@@QAE@XZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: char * __thiscall std::allocator::allocate(unsigned int)" (?allocate@?$allocator@D@std@@QAEPADI@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::allocator::deallocate(char *,unsigned int)" (?deallocate@?$allocator@D@std@@QAEXPADI@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::allocator::allocator(class std::allocator const &)" (??0?$allocator@D@std@@QAE@ABV01@@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: unsigned int __thiscall std::allocator::max_size(void)const " (?max_size@?$allocator@D@std@@QBEIXZ) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::basic_string,class std::allocator >::compare(class std::basic_string,class std::allocator > const &)const " (?compare@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEHABV12@@Z) already defined in USBInfo.lib(USBInfoInterface.obj)
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/comsupp.lib:
Searching F:/New MicrosoftSDK/Lib/user32.lib:
Searching F:/New MicrosoftSDK/Lib/ole32.lib:
Searching F:/New MicrosoftSDK/Lib/oleaut32.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/atlsd.lib:
Searching F:/New MicrosoftSDK/Lib/kernel32.lib:
Searching F:/New MicrosoftSDK/Lib/advapi32.lib:
Searching F:/New MicrosoftSDK/Lib/shell32.lib:
Searching F:/New MicrosoftSDK/Lib/shlwapi.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/mfc80d.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/mfcs80d.lib:
Searching F:/New MicrosoftSDK/Lib/gdi32.lib:
Searching F:/New MicrosoftSDK/Lib/msimg32.lib:
Searching F:/New MicrosoftSDK/Lib/comdlg32.lib:
Searching F:/New MicrosoftSDK/Lib/winspool.lib:
Searching F:/New MicrosoftSDK/Lib/comctl32.lib:
Searching F:/New MicrosoftSDK/Lib/oledlg.lib:
Searching F:/New MicrosoftSDK/Lib/urlmon.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/msvcrt.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/libcpmtd.lib:
Searching F:/New MicrosoftSDK/Lib/mswsock.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/msvcrtd.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/libcmtd.lib:
Searching ../Output/Debug/USBInfo.lib:
Searching ../../Library Source Code/xerces/lib/xerces-c_2D.lib:
Searching ../../Library Source Code/lib/u3dapi10.lib:
Searching ../../Library Source Code/lib/libeay32.lib:
Searching ../../Library Source Code/lib/libcurl.lib:
Searching ../../Librar~1/lib/Zlib.lib:
Searching F:/New MicrosoftSDK/Lib/ws2_32.lib:
Searching ../Output/Debug/FPHelper.lib:
Searching ../../Debug/CryptoInterface/CryptoInterface.lib:
Searching ../../Debug/FBCommonDLL/FBCommonDll.lib:
Searching F:/New MicrosoftSDK/Lib/Netapi32.lib:
Searching F:/New MicrosoftSDK/Lib/psapi.lib:
Searching F:/New MicrosoftSDK/Lib/Mpr.lib:
Searching F:/New MicrosoftSDK/Lib/Wininet.lib:
Searching F:/New MicrosoftSDK/Lib/version.lib:
Searching F:/New MicrosoftSDK/Lib/Pdh.lib:
Searching ../Output/Debug/DeviceInfo.lib:
Searching F:/New MicrosoftSDK/Lib/setupapi.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/OLDNAMES.lib:
Searching F:/New MicrosoftSDK/Lib/uuid.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/msvcprtd.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/lib/comsupp.lib:
Searching F:/New MicrosoftSDK/Lib/user32.lib:
Searching F:/New MicrosoftSDK/Lib/ole32.lib:
Searching F:/New MicrosoftSDK/Lib/oleaut32.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/atlsd.lib:
Searching F:/New MicrosoftSDK/Lib/kernel32.lib:
Searching F:/New MicrosoftSDK/Lib/advapi32.lib:
Searching F:/New MicrosoftSDK/Lib/shell32.lib:
Searching F:/New MicrosoftSDK/Lib/shlwapi.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/mfc80d.lib:
Searching D:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/lib/mfcs80d.lib:
Searching F:/New MicrosoftSDK/Lib/gdi32.lib:
Searching F:/New MicrosoftSDK/Lib/msimg32.lib:
Searching F:/New MicrosoftSDK/Lib/comdlg32.lib:
Searching F:/New MicrosoftSDK/Lib/winspool.lib:
Searching F:/New MicrosoftSDK/Lib/comctl32.lib:
Searching F:/New MicrosoftSDK/Lib/oledlg.lib:
Searching F:/New MicrosoftSDK/Lib/urlmon.lib:
Finished searching libraries
msvcrtd.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
./../Output/Debug/KPActivator.exe : fatal error LNK1169: one or more multiply defined symbols found
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version 8.00.50727
Copyright (C) Microsoft Corporation. All rights reserved.
Build log was saved at "file://e:/PORTAL_build 51/KeyPoint/IntermediateFiles/Debug/KPActivator/BuildLog.htm"
KPActivator - 24 error(s), 34 warning(s)

 

==============================================================

The problem was because of different Run-Time library settings.

当前工程和Lib工程使用的Run-Time library 不一致。

 

这些选项选择单线程或多线程运行时例程,指示多线程模块是否为 DLL,并选择运行时库的发布版本或调试版本。


选项 说明
/MD 定义 _MT_DLL 以便同时从标准 .h 文件中选择运行时例程的多线程特定版本和 DLL 特定版本。此选项还使编译器将库名 MSVCRT.lib 放入 .obj 文件中。

用此选项编译的应用程序静态链接到 MSVCRT.lib。该库提供允许链接器解析外部引用的代码层。实际工作代码包含在 MSVCR71.DLL 中,该库必须在运行时对于与 MSVCRT.lib 链接的应用程序可用。

当 在定义了 _STATIC_CPPLIB (/D_STATIC_CPPLIB) 的情况下使用 /MD 时,它将导致应用程序通过静态多线程标准 C++ 库 (libcpmt.lib) 而非动态版本 (msvcprt.lib) 进行链接,同时仍通过 msvcrt.lib 动态链接到主 CRT。

/MDd 定义 _DEBUG_MT_DLL,以便从标准 .h 文件中选择运行时例程的调试多线程特定版本和 DLL 特定版本。它还使编译器将库名 MSVCRTD.lib 放入 .obj 文件中。
/ML 使编译器将库名 LIBC.lib 放入 .obj 文件中,以便链接器使用 LIBC.lib 解析外部符号。这是编译器的默认操作。LIBC.lib 不提供多线程支持。
/MLd 定义 _DEBUG 并使编译器将库名 LIBCD.lib 放入 .obj 文件中,以便链接器使用 LIBCD.lib 解析外部符号。LIBCD.lib 不提供多线程支持。
/MT 定义 _MT, 以便从标准头 (.h) 文件中选择运行时例程的多线程特定版本。此选项还使编译器将库名 LIBCMT.lib 放入 .obj 文件中,以便链接器使用 LIBCMT.lib 解析外部符号。创建多线程程序需要 /MT 或 /MD(或它们的调试等效选项 /MTd 或 /MDd)。
/MTd 定义 _DEBUG_MT。定义 _MT 会导致从标准 .h 文件中选择运行时例程的多线程特定版本。此选项还使编译器将库名 LIBCMTD.lib 放入 .obj 文件中,以便链接器使用 LIBCMTD.lib 解析外部符号。创建多线程程序需要 /MTd 或 /MDd(或它们的非调试等效选项 /MT 或 MD)。
/LD 创建 DLL。

将 /DLL 选项传递到链接器。链接器查找 DllMain 函数,但并不需要该函数。如果没有编写 DllMain 函数,链接器将插入返回 TRUE 的 DllMain 函数。

链接 DLL 启动代码。

如果命令行上未指定导出 (.exp) 文件,则创建导入库 (.lib);将导入库链接到调用您的 DLL 的应用程序。

/Fe 解释为命名 DLL 而不是 .exe 文件;默认程序名成为基名称.dll 而不是基名称.exe。

如果还未显式指定 /M 选项之一,则将默认运行时库支持更改为 /MT。

/LDd 创建调试 DLL。定义 _DEBUG
警告    不要混合使用运行时库的静态版本和动态版本。在一个进程中有多个运行时库副本会导致问题,因为副本中的静态数据不与其他副本共享。链接器禁止在 .exe 文件内部既使用静态版本又使用动态版本链接,但您仍可以使用运行时库的两个(或更多)副本。例如,当与用动态 (DLL) 版本的运行时库链接的 .exe 文件一起使用时,用静态(非 DLL)版本的运行时库链接的动态链接库可能导致问题。(还应该避免在一个进程中混合使用这些库的调试版本和非调试版本)。

有关使用运行时库的调试版本的更多信息,请参见运行时库参考。

知识库文章 Q140584 也讨论如何选择适当的 C 运行时库。

有关 DLL 的进一步讨论,请参见 DLL

在 Visual Studio 开发环境中设置此编译器选项

  1. 打开此项目的“属性页”对话框。有关详细信息,请参见设置 Visual C++ 项目属性
  2. 单击“C/C++”文件夹。
  3. 单击“代码生成”属性页。
  4. 修改“运行时库”属性。

关于Visual C++ 编译器选项的说明:

 

你可能感兴趣的:(编译器VC,Compile,Error)