Include Google test to your vs2015 project
To include Google test to your visual studio project you just need to follow the steps below
- Download Googletest from Github and copy all the file in it’s own folder.
You only need the folder called “googletest” other files are for github and so on. - Create a library
- Add a new empty project
Right click the solution, Add > New Project …, “Win 32 project” - Give it a name “googletest”
 - Make sure that the directory is relative to your project, (the default is somewhere weird and wonderful in your %appdata% I think).
 - Select the option “Static Library”, “empty project” and it should have no files in it.
 - Uncheck the “Precompiled header” and press “Finish”
 - Add gtest_main.cc and gtest-all.cc to that project, (they are located in the googletest\src\ folder of the files you just downloaded.
 - Compile that project, and note where the googletest.lib file is created.
 
 - Add a new empty project
 - In your test project,
- Right click > Properties > C++ > General
 - In the part for “Additional include libraries” add the path to the google test folder and include folder.
For example, “..\googletest\include;..\googletest\”. - There might already be a folder called “%(AdditionalIncludeDirectories)”.
 - Right click > Properties > Linker > General
 - In the part for “”Additional Library directories” add the directory where the googletest.lib file was created, (the library, not the file).
 - Finaly, add a reference, (Right Click the project > References and add googletest).
 
 
Be sure to set the references and include libraries for all your configurations, “Release”, “Debug”, x32, x64 and so on.
NB: Of course you can just build the lib and include it as a library, but that way when Googletest does an update, you just need to replace the code, and life is good again!
Recent Comments