Google のテスト サンプルをコンパイル/ビルドしようとしましたが、サンプルを動作させることができなかったので、代わりに単純化を試みることにしました。単体テストをセットアップし、Google テストを使用して実行する方法を詳しく説明しているこのビデオを見つけました (代わりにコマンド ラインから): http://vimeo.com/53690756
ただし、ソース コードが正しく実装されていると仮定し、プロジェクトのプロパティに移動して、C/C++ の追加インクルード ディレクトリを g-test-1.6.0 インクルード ディレクトリに設定し、リンカーの追加ライブラリ ディレクトリを同じ g-test-1.6 に設定しました。 .0 インクルード ディレクトリ。ただし、リンカー>入力>追加の依存関係、gtestd.libを記述しました。
私が得る唯一のエラーは 101 error LNK1103: cannot open file 'gtestd.lib' です。ビデオから得られなかったのは、静的ライブラリ ファイルの生成方法でしょうか? 以前に別のプロジェクトでデバッグを使用してビルドを実行したとき、デバッグの下に gtestd.lib ファイルを取得でき、そのファイルを g-test-1.6.0 インクルード ディレクトリに含めようとしましたが、代わりに 65 リンカー エラーが発生しました。 .
基本的に、私が求めているのは、Visual Studio 2010 でライブラリまたはリンカー エラーを発生させずに Google テストをセットアップする方法です。gtest.lib または gtestd.lib の適切なバージョンはどこで入手できますか? また、そのライブラリ ファイルはどこに配置すれば見つけられるのでしょうか?
受け取ったリンカー エラーのいくつかを次に示します。
Warning 65 warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LINK Testproject99
Warning 66 warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LINK Testproject99
Error 64 error LNK2005: _vprintf already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(vprintf.obj) Testproject99
Error 59 error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(strtol.obj) Testproject99
Error 58 error LNK2005: _sprintf_s already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(sprintf.obj) Testproject99
Error 63 error LNK2005: _printf already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(printf.obj) Testproject99
Error 49 error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(crt0.obj) Testproject99
Error 45 error LNK2005: _localeconv already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(lconv.obj) Testproject99
Error 44 error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(fflush.obj) Testproject99
Error 39 error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(crt0dat.obj) Testproject99
Error 50 error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(winxfltr.obj) Testproject99
Error 62 error LNK2005: __vsnprintf_s already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(vsnprnc.obj) Testproject99
Error 48 error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(mlock.obj) Testproject99
Error 60 error LNK2005: __strtoui64 already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(strtoq.obj) Testproject99
Error 37 error LNK2005: __open_osfhandle already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(osfinfo.obj) Testproject99
Error 47 error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(mlock.obj) Testproject99
Error 57 error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(invarg.obj) Testproject99
Error 56 error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\LIBCMTD.lib(invarg.obj) Testproject99
Error 29 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) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\libcpmtd.lib(locale0.obj) Testproject99
Error 23 error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 22 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 gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 3 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 gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 32 error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\libcpmtd.lib(xlock.obj) Testproject99
Error 31 error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP100D.dll) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\libcpmtd.lib(xlock.obj) Testproject99
Error 18 error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 21 error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 11 error LNK2005: "protected: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *,char *)" (?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z) already defined in gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 8 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 gtestd.lib(gtest-all.obj) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\msvcprtd.lib(MSVCP100D.dll) Testproject99
Error 27 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) C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Testproject99\libcpmtd.lib(locale0.obj) Testproject99
Error 67 error LNK1169: one or more multiply defined symbols found C:\Users\smorsi\Documents\Visual Studio 2010\Projects\Testproject99\Debug\Testproject99.exe Testproject99
Chemistpp の手順に従って最初からやり直し、「_VARIADIC_MAX=10」をプリプロセッサに追加すると、ソリューションのビルド時にこれらの警告が表示されました (エラーはありません)。
Warning 108 warning MSB8012: TargetPath(C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md/Debug\gtest_unittest-md.exe) does not match the Linker's OutputFile property value (C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md\Debug\gtest_unittest.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 990 6 gtest_unittest-md
Warning 106 warning MSB8012: TargetPath(C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md/Debug\gtest_prod_test-md.exe) does not match the Linker's OutputFile property value (C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md\Debug\gtest_prod_test.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 990 6 gtest_prod_test-md
Warning 104 warning MSB8012: TargetPath(C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md/Debug\gtest_main-md.lib) does not match the Library's OutputFile property value (C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md\Debug\gtest_main-mdd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 1151 6 gtest_main-md
Warning 102 warning MSB8012: TargetPath(C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md/Debug\gtest-md.lib) does not match the Library's OutputFile property value (C:\Users\smorsi\Desktop\gtest-1.6.0\gtest-1.6.0\msvc\gtest-md\Debug\gtestd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 1151 6 gtest-md
Warning 109 warning MSB8012: TargetName(gtest_unittest-md) does not match the Linker's OutputFile property value (gtest_unittest). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 992 6 gtest_unittest-md
Warning 107 warning MSB8012: TargetName(gtest_prod_test-md) does not match the Linker's OutputFile property value (gtest_prod_test). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 992 6 gtest_prod_test-md
Warning 105 warning MSB8012: TargetName(gtest_main-md) does not match the Library's OutputFile property value (gtest_main-mdd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 1153 6 gtest_main-md
Warning 103 warning MSB8012: TargetName(gtest-md) does not match the Library's OutputFile property value (gtestd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile). C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 1153 6 gtest-md