Cannot get google test to work

#include "gtest/gtest.h"

TEST(BattleUnitTest, CountryReturnsProperName) {
    EXPECT_EQ(1, 1);
}

int main(int argc, char* argv[]) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

I can not get Google to work. I started the Nuget package manager to get gtest. He continues to give me these errors:

Severity    Code    Description Project File    Line
Error   LNK2019 unresolved external symbol "bool __cdecl testing::internal::IsTrue(bool)" (?IsTrue@internal@testing@@YA_N_N@Z) referenced in function "public: void __thiscall testing::internal::scoped_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::reset(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?reset@?$scoped_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@internal@testing@@QAEXPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) Assignment1_Battle  E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj    1

.

    Severity    Code    Description Project File    Line
Error   LNK2019 unresolved external symbol "public: __thiscall testing::Message::Message(void)" (??0Message@testing@@QAE@XZ) referenced in function "private: virtual void __thiscall BattleUnitTest_CountryReturnsProperName_Test::TestBody(void)" (?TestBody@BattleUnitTest_CountryReturnsProperName_Test@@EAEXXZ)    Assignment1_Battle  E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj    1

.

Severity    Code    Description Project File    Line
Error   LNK2019 unresolved external symbol "class testing::AssertionResult __cdecl testing::internal::EqFailure(char const *,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?EqFailure@internal@testing@@YA?AVAssertionResult@2@PBD0ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@1_N@Z) referenced in function "class testing::AssertionResult __cdecl testing::internal::CmpHelperEQ<int,int>(char const *,char const *,int const &,int const &)" (??$CmpHelperEQ@HH@internal@testing@@YA?AVAssertionResult@1@PBD0ABH1@Z) Assignment1_Battle  E:\C++\Projects\Assignment1_Battle\Assignment1_Battle\BattleUnitTest.obj    1

I can post all the errors, but almost all of them are related to LNK2019. Does anyone know how to fix these errors?

+1
source share
2 answers

It looks like you need additional customization of your test project:

  1. gtest (Project Properties-> Configuration Properties-> Linker-> Input). , , , Debug, Release, ( gtest.lib Release gtestd.lib Debug; - "d") ).
  2. gtest (Project Properties-> Configuration Properties-> V++ Directories-> ). Debug Release, .

- , . gtest Visual Studio Nuget. , Nuget gtest "package" /.

0

, . PrintTo link:

/Zc: wchar_t. , Qt Console Application ( Qt 1.1.9). -, wchar_t "" , Google Mock "" . Google Mock "", .

" WChar_t As Built in Type" "Yes/Zc: wchar_t", .

0

All Articles