Here is excellent guide for setting up google-test in Visual Studio. Unfortunately, it omits whether one should build gtest always for win32 or for the same platform as the project being tested (step 3 of 2nd paragraph). So how should I build gtest if my "main" project is going to be built for x64 (native c++)? Does it matter?
Asked
Active
Viewed 2,794 times
3 Answers
0
It depends on the build of the libraries you intend to test. If you build your libraries x64, then you'll need an x64 build of gtest. Otherwise you'll need 32bit gtest.

HughB
- 363
- 2
- 12
-
I confirm that everything work with both x64 builds of gtest and of my libraries. Thanks! However, I hesitate to accept the answer because I have not checked whether it would work with 32bit build of gtest and x64 build of my library. If it does, then answer "always build gtest as 32bit" would be more appropriate. If you tell that you checked it, and building gtest for 32bit doesn't work, then I'll accept. – Dmitry J Mar 11 '17 at 00:28
-
http://stackoverflow.com/questions/1943681/linking-32-bit-library-to-64-bit-program – HughB Mar 13 '17 at 17:34
0
It is very important to build gtest with the same compiler and the same compiler settings.
That means in your case: use the same msvc compiler, e.g. Visual Studio 14 2015 win64.
In Addition the Runtime Library have to be the same (A mistake I've made in the past). You can set the Runtime Library in Visual Studio in:
Configuration Properties - C/C++ - Code Generation
If you build static libs, set it to MTd.

Soeren
- 1,725
- 1
- 16
- 30
0
you can generate visual studio 2015 X64 project files by the follow commands: cmake -G "Visual Studio 14 2015 Win64"