搭建使用Crypto++的开发环境

使用Crypto++需要用到cryptolib,生成方法可以参考我以前的一篇文章:Visual Studio 2010下生成Crypto++ lib

我的开发环境如下:

Visual Studio 2010、Crypto++5.6.0

新建一个"Win32 Console Application"的空工程后,在以下地方修改工程属性(Alt + F7):

1. "Configuration Properties C/C++ General Addtional Include Directories"中添加Crypto++路径,如:C:\Program Files\CryptoPP\include

2. "Configuration Properties Linker General Addtional Library Directories"中添加Crypto++路径,如:C:\Program Files\CryptoPP\lib

3. "Configuration Properties C/C++ Code Generation Runtime Library"中修改为:Multi-threaded Debug (/MTd) (debug下)或 Multi-threaded (/MT) (release下)

此时,使用Crypto++的开发环境就搭建好了。在Crypto++ User Guide中的例子(如Cryptlib.h)就能正常编译运行了,这里我提供了Cryptlib.h中例子的工程,点击下载

   

注意,若缺少上述的第3步,将出现如下链接错误:

1>cryptlib.lib(hex.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(hex.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(hex.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(filters.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(filters.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(filters.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(cryptlib.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(basecode.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(basecode.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(basecode.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(files.obj) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(crc.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(crc.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(crc.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(iterhash.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(iterhash.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(iterhash.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(md5.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(md5.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(md5.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(algparam.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(algparam.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(algparam.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(mqueue.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(queue.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(queue.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>cryptlib.lib(queue.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>libcpmtd.lib(syserror.obj) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>libcpmtd.lib(syserror.obj) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>libcpmtd.lib(syserror.obj) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP100D.dll)

1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)

1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __aligned_malloc already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __aligned_free already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(_ctype.obj) : error LNK2005: _isalpha already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(_file.obj) : error LNK2005: __lock_file already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(_file.obj) : error LNK2005: __unlock_file already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)

1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)

1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)

1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)

1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)

1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR100D.dll)

1>LIBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR100D.dll)

   

若使用的"cryptlib.lib"不是使用相同版本的Visual Studio生成的话,也会出现一些LNK错误。

posted @ 2010-07-30 16:28  cxun  阅读(2808)  评论(0编辑  收藏  举报