使用Crypto++库编译出错 解决办法
错误信息:
1 1>------ 已启动生成: 项目: testCrypto++, 配置: Debug Win32 ------ 2 1>正在编译... 3 1>main.cpp 4 1>正在链接... 5 1>cryptlib.lib(rijndael.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 6 1>cryptlib.lib(rijndael.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 7 1>cryptlib.lib(rijndael.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 8 1>cryptlib.lib(rijndael.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 9 1>cryptlib.lib(rijndael.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 10 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 11 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 12 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 13 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 14 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 15 1>cryptlib.lib(cryptlib.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 16 1>cryptlib.lib(filters.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 17 1>cryptlib.lib(filters.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 18 1>cryptlib.lib(filters.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 19 1>cryptlib.lib(filters.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 20 1>cryptlib.lib(filters.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 21 1>cryptlib.lib(filters.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 22 1>cryptlib.lib(queue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 23 1>cryptlib.lib(queue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 24 1>cryptlib.lib(queue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 25 1>cryptlib.lib(queue.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 26 1>cryptlib.lib(queue.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 27 1>cryptlib.lib(algparam.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 28 1>cryptlib.lib(algparam.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 29 1>cryptlib.lib(algparam.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 30 1>cryptlib.lib(algparam.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 31 1>cryptlib.lib(algparam.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 32 1>cryptlib.lib(algparam.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 33 1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 34 1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 35 1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 36 1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 37 1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 38 1>cryptlib.lib(mqueue.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 39 1>libcpmtd.lib(string.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 40 1>libcpmtd.lib(string.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 41 1>libcpmtd.lib(string.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 42 1>libcpmtd.lib(string.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 43 1>libcpmtd.lib(string.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) 已经在 msvcprtd.lib(MSVCP90D.dll) 中定义 44 1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __aligned_malloc 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 45 1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __aligned_free 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 46 1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 47 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 48 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 49 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 50 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 51 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 52 1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 53 1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 54 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 55 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 56 1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 57 1>LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup 已经在 MSVCRTD.lib(crtexe.obj) 中定义 58 1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 59 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a 已经在 MSVCRTD.lib(cinitexe.obj) 中定义 60 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z 已经在 MSVCRTD.lib(cinitexe.obj) 中定义 61 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a 已经在 MSVCRTD.lib(cinitexe.obj) 中定义 62 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z 已经在 MSVCRTD.lib(cinitexe.obj) 中定义 63 1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 64 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 65 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 66 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 67 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 68 1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW 已经在 MSVCRTD.lib(MSVCR90D.dll) 中定义 69 1>LINK : warning LNK4098: 默认库“MSVCRTD”与其他库的使用冲突;请使用 /NODEFAULTLIB:library 70 1>LINK : warning LNK4098: 默认库“LIBCMTD”与其他库的使用冲突;请使用 /NODEFAULTLIB:library 71 1>C:\Users\Administrator\Documents\Visual Studio 2008\Projects\test\Debug\testCrypto++.exe : fatal error LNK1169: 找到一个或多个多重定义的符号 72 1>生成日志保存在“file://c:\Users\Administrator\Documents\Visual Studio 2008\Projects\test\testCrypto++\Debug\BuildLog.htm” 73 1>testCrypto++ - 65 个错误,2 个警告 74 ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
错误原因:crypto++库是MTD模式下的,而vs2008的默认运行时库是多线程MDd
解决办法:项目属性--配置属性--C/C++--代码生成 运行时库修改为:多线程调试DLL(/MTd)
关于运行时库的详细说明请点击这里