I tried compiling/building the google test samples but I decided to try something simplifier instead when I couldn't get the samples to work. I found this video that details how to set up the unit tests and run them using google test (but from the command line instead): http://vimeo.com/53690756
However, assuming the source code is correctly implemented and I went to my project's properties and set the C/C++'s Additional Include Directories to the g-test-1.6.0 include directory and the Linker's Additional library directories to the same g-test-1.6.0 include directory. However, Linker > Input > Additional Dependencies, I wrote gtestd.lib.
The only error I get is 101 error LNK1103: cannot open file 'gtestd.lib', I guess what I didn't get from the video is how they generated that static library file? When I ran the build using debug previously on another project, I was able to get a gtestd.lib file under Debug and I tried to include that file under the g-test-1.6.0 include directory but then I got 65 linker errors instead.
Essentially, what I'm asking is how to set up google test in Visual Studio 2010 without getting a library or linker error? Where do I get the proper version of gtest.lib or gtestd.lib and where should I place that library file so it's found?
Here are a few of the linker errors I'm receiving:
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
I started over following Chemistpp's steps and When I added "_VARIADIC_MAX=10" to Preprocessor, I got these warnings (but no errors) when building the solutions.
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