c – 我需要链接哪些库来构建googlemock示例?

c – 我需要链接哪些库来构建googlemock示例?,第1张

概述我能够在VS2010中编译googlemock v1.6.x并生成发布和调试库.换句话说,我遇到的问题不是这个 GoogleMock and GoogleTest in Visual Studio 2010 现在我正在关注这里的例子http://code.google.com/p/googlemock/wiki/ForDummies,我遇到了这些错误.我确实链接了生成的* .lib文件,并在VS2 我能够在VS2010中编译Googlemock v1.6.x并生成发布和调试库.换句话说,我遇到的问题不是这个 GoogleMock and GoogleTest in Visual Studio 2010

现在我正在关注这里的例子http://code.google.com/p/googlemock/wiki/ForDummies,我遇到了这些错误.我确实链接了生成的* .lib文件,并在VS2010中添加了正确的库目录.那我还需要链接什么呢?

1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(voID)" (??1_Container_base12@std@@QAE@XZ) already defined in gmockd.lib(gmock-all.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 gmockd.lib(gmock-all.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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(voID)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: virtual __thiscall std::basic_iostream<char,struct std::char_traits<char> >::~basic_iostream<char,struct std::char_traits<char> >(voID)" (??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::basic_iostream<char,struct std::char_traits<char> >::basic_iostream<char,struct std::char_traits<char> >(class std::basic_streambuf<char,struct std::char_traits<char> > *)" (??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: __thiscall std::basic_ios<char,struct std::char_traits<char> >::basic_ios<char,struct std::char_traits<char> >(voID)" (??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(voID)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::gptr(voID)const " (?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: voID __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::setg(char *,char *,char *)" (?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: voID __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *)" (?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::eback(voID)const " (?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Pninc(voID)" (?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: voID __thiscall std::basic_streambuf<char,char *)" (?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::pbase(voID)const " (?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::epptr(voID)const " (?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::pptr(voID)const " (?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: voID __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::gbump(int)" (?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::egptr(voID)const " (?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: voID __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::pbump(int)" (?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "protected: __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::basic_streambuf<char,struct std::char_traits<char> >(voID)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in gmockd.lib(gmock-all.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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : 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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::wIDth(__int64)" (?wIDth@ios_base@std@@QAE_J_J@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : 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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : 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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(voID)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QbedXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(voID)const " (?flags@ios_base@std@@QBEHXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::wIDth(voID)const " (?wIDth@ios_base@std@@QBE_JXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class 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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(voID)const " (?good@ios_base@std@@QBE_NXZ) already defined in gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : 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 gmockd.lib(gmock-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> >::operator<<(unsigned int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z) already defined in gmockd.lib(gtest-all.obj)1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(voID)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in gmockd.lib(gmock-all.obj)1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static voID __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP100D.dll)1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static voID __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP100D.dll)1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static voID __cdecl std::locale::facet::_Facet_Register(class std::locale::facet *)" (?_Facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprtd.lib(locale0_implib.obj)1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(voID)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(voID)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static voID __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in msvcprtd.lib(MSVCP100D.dll)1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static voID __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) 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(_file.obj) : error LNK2005: ___iob_func 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(dbgheap.obj) : error LNK2005: __free_dbg 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(osfinfo.obj) : error LNK2005: __open_osfhandle already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(dosmap.obj) : error LNK2005: __errno 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(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(lconv.obj) : error LNK2005: _localeconv 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(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(winxfltr.obj) : error LNK2005: __XcptFilter 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(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(sprintf.obj) : error LNK2005: _sprintf_s already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(strtoq.obj) : error LNK2005: __strtoui64 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(vsnprnc.obj) : error LNK2005: __vsnprintf_s already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(printf.obj) : error LNK2005: _printf already defined in MSVCRTD.lib(MSVCR100D.dll)1>liBCMTD.lib(vprintf.obj) : error LNK2005: _vprintf already defined in MSVCRTD.lib(MSVCR100D.dll)1>link : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAulTliB:library1>link : warning LNK4098: defaultlib 'liBCMTD' conflicts with use of other libs; use /NODEFAulTliB:library1>liBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup1>C:\documents and Settings\fouts\My documents\Visual Studio 2010\GMockTest\DeBUG\GMockTest.exe : Fatal error LNK1120: 1 unresolved externals1>
解决方法 这看起来你在选择C Runtime和C标准库时遇到了不匹配.

您可以使用编译器开关/ MT,/ MTd,/ MD或/ MDd在这些版本的静态(.lib)或共享(DLL)版本之间进行选择. MT变体表示静态库,MD表示共享.附录d表示每个的调试版本.

这些可以通过转到Project =>在Visual Studio中设置.属性=>配置属性=> C/C++ =>代码生成=>运行时库

问题似乎是您的项目使用/ MD和/ MDd,但GMock和Gtest是使用/ MT和/ MTd构建的.您需要使用/ MD和/ MDd标志重新编译GMock / Gtest,或将您的更改为/ MT和/ MTd.

总结

以上是内存溢出为你收集整理的c – 我需要链接哪些库来构建googlemock示例?全部内容,希望文章能够帮你解决c – 我需要链接哪些库来构建googlemock示例?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1234930.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存