Search code examples
visual-c++googlemock

gmock and gtest linker errors in vc++ 2015 community edition


I'm tyring to configure gmock/gtest in vc++ 2015, namely

  1. downloaded gmock and gtest

  2. added E:\googlemock\googletest\include and E:\googlemock\googlemock\include in VC++ include directories.

  3. compiled gmock.sln and added E:\googlemock\googlemock\msvc\2015\Debug to the Library directories.

  4. added gmock.lib to Linker -> Input Additional dependencies.

And on building I'm getting a bunch of linker errors as below.

As i don't have any clue about the gmock/ gtest code. How shall I reason / proceed further in fixing these problems ?

code:

int main(int argc, char **argv)
{
    testing::InitGoogleMock(&argc, argv);
    return RUN_ALL_TESTS();
}
Error   **LNK2038** mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in ArrayOperations.obj   ConsoleApplication3 E:\projects\cpp\ConsoleApplication3\ConsoleApplication3\gmock.lib(gtest-all.obj)    
Error   **LNK2005** "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in gmock.lib(gtest-all.obj) ConsoleApplication3 E:\projects\cpp\ConsoleApplication3\ConsoleApplication3\msvcprtd.lib(MSVCP140D.dll) 1   

and more bunch of errors on the same LNK category*


Solution

  • Finally I could solve the problem by adding in properties -> c++ code generation

    Run time Library to Multi-threaded Debug (/MTd) as from the post.

    Mismatch Detected for 'RuntimeLibrary'