Search code examples
c++visual-studiogoogletest

Adding dependencies to googletest?


I have a win32 console application project in c++ with several external libraries being used.

I created a Google Test project and added my original project as a reference, however the test project keeps saying several files are missing when I build it.

Is adding my project as a reference not enough or do I need to individually add the files and external libraries to my test project?

Or is there a workaround? I'm using VS2017

Thank you.


Solution

  • Adding your application as a reference to your unit tests does not help Visual Studio find the relevant C++ sources and external libraries. You have to add the relevant application C++ sources to your test project (Add existing item), specify the path of your application include files and add any required external libraries.

    Using a reference is useful when the project under test is a library. VS will then automatically (re)build the library when you run the tests.