c – 在MFC中使用静态库

我尝试在我的MFC项目中使用静态库,但是我收到以下链接错误
1>------ Build started: Project: Csetkliens,Configuration: Debug Win32 ------
1>Build started 2012.05.20. 16:12:49.
1>InitializeBuildStatus:
1>  Touching "Debug\Csetkliens.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  All outputs are up-to-date.
1>ResourceCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj)
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in Csetkliens.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in Csetkliens.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in Csetkliens.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " (?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@XZ) already defined in Csetkliens.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmtd.lib(xthrow.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: __invalid_parameter already defined in libcmtd.lib(invarg.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: __CrtDbgReportW already defined in libcmtd.lib(dbgrptw.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in libcmtd.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in libcmtd.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in libcmtd.lib(stdexcpt.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _memmove already defined in libcmtd.lib(memmove.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _malloc already defined in libcmtd.lib(dbgmalloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _realloc already defined in libcmtd.lib(dbgrealloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _fflush already defined in libcmtd.lib(fflush.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: ___iob_func already defined in libcmtd.lib(_file.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in libcmtd.lib(dbgfree.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _floor already defined in libcmtd.lib(_floor_pentium4_.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _ldexp already defined in libcmtd.lib(_ldexp_.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _abort already defined in libcmtd.lib(abort.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _isspace already defined in libcmtd.lib(_ctype.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmtd.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcmtd.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>D:\Projektek\V.felev\Felulettervezes (MFC) - Halozatok\Csetkliens\Debug\Csetkliens.exe : Fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build Failed.
1>
1>Time Elapsed 00:00:02.29
========== Build: 0 succeeded,1 Failed,0 up-to-date,0 skipped ==========

静态库的名称是kriptolib.lib,它是我自己的产品.它不使用任何MFC.我无法弄清楚问题是什么.

当我尝试从kriptolib创建一个新对象时,会出现问题.

theApp.encryption = new RC4();

如果我评论下面的行,编译器不会显示任何错误.

解决方法

您需要更改测试项目以使用MTd(多线程调试).

属性页面中选择配置属性==> C/C++ ==>代码生成==>运行时库==>多线程调试(/ MTd).

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...