0

I have the following problem, I am trying to add testing the my project and opted for GTest.
Downloaded from nuget like all the mortals and while compiling have the following error:

 error LNK2038: mismatch detected for '_MSC_VER': value '1800' doesn't match value '1900' in Source.obj

Followed by quite a few unresolved external linking errors.
As far as I understand there is a versioning problem here, but none of the answers on SO was useful for me.
This is the simplest example I use:

#define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING  1
#define GTEST_LANG_CXX11 1

#include <iostream>
#include <gtest/gtest.h>

struct Account 
{
    int balance;
    Account() = default;
    explicit Account(const int& bal) :
        balance{ bal } 
    {}
};

TEST(AccountTest, AccountEmpty) 
{
    Account acc;
    EXPECT_EQ(0, acc.balance);
}

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

VS version 2019
GTest version 1.7.0

Has anyone has encountered this issue or does anyone have an idea how to solve it?

prehistoricpenguin
  • 6,130
  • 3
  • 25
  • 42
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
  • Sources.cpp is your file, not gtest's. Show the compiler options and toolchain used. I guess your question is a duplicate of https://stackoverflow.com/questions/4061929/linker-error-lnk2038-mismatch-detected-in-release-mode/4061953. – 273K Aug 25 '21 at 15:06
  • `#define GTEST_LANG_CXX11 1` must not be used. Set the appropriate compiler setting `/Zc:__cplusplus`. – 273K Aug 25 '21 at 15:08
  • You need a newer GTest version. – Cosmin Aug 25 '21 at 16:31

0 Answers0