Reputation: 26333
I have a solution which was compiled with compiler VS2008. It was working perfect. It is instrumented with Google Test and the Google Test library is linked to the solution. the gtest.lib
should be compiled with the same compiler as the solution itself, as far as I know.
Now, I have to compile this same solution with VS2013. I get this compilation error
Error 3 error LNK2038: mismatch detected for '_MSC_VER':
value '1700' doesn't match value '1800'
I think that I should get the library for Google Test compiled with Visual Studio 2013.
I cannot find such thing. Could you give me a hint at the Google Test library I should go for ?
Upvotes: 1
Views: 1143
Reputation: 5667
Note that there's a native GTEST package on NuGet which contains a gtest.lib
. Has the additional benefit of making the gtest include
folder automatically available.
Upvotes: 0
Reputation: 1
The linker error you get is pretty obvious: You need a gtest.lib
compiled with VS2013.
"I think that I should get the library for Google Test compiled with Visual Studio 2013."
Exactly, so just do that.
"Could you give me a hint at the Google Test library I should go for ?"
Well, no more as to cite from the google test primer documentation (emphasis mine), sorry (I doubt you can reliably download a proper binary elsewhere):
Setting up a New Test Project
To write a test program using Google Test, you need to compile Google Test into a library and link your test with it. We provide build files for some popular build systems: msvc/ for Visual Studio, xcode/ for Mac Xcode, make/ for GNU make, codegear/ for Borland C++ Builder, and the autotools script (deprecated) and CMakeLists.txt for CMake (recommended) in the Google Test root directory. If your build system is not on this list, you can take a look at make/Makefile to learn how Google Test should be compiled (basically you want to compile src/gtest-all.cc with GTEST_ROOT and GTEST_ROOT/include in the header search path, where GTEST_ROOT is the Google Test root directory).
Once you are able to compile the Google Test library, you should create a project or build target for your test program. Make sure you have GTEST_ROOT/include in the header search path so that the compiler can find "gtest/gtest.h" when compiling your test. Set up your test project to link with the Google Test library (for example, in Visual Studio, this is done by adding a dependency on gtest.vcproj).
If you still have questions, take a look at how Google Test's own tests are built and use them as examples.
I personally prefer to build the test runner using the src/gtest-all.cc
to be built and linked with my test-projects from source. That's the most simple and mostly portable way IMHO (using e.g. your custom GNU makefiles).
As said in the comment on your OP, you can easily do a "prebuild" just using your VS2013 compiler, to link with it from other projects.
Upvotes: 1