2
votes

I'm getting started with Google Test for C++. Unfortunately I'm having trouble trying to include the header files. The first line of my little test program sumTest.cpp says

#include "gtest/gtest.h"

while subTest.cpp is in the same directory as gtest . gtest also contains the directory called internal, which contains gtest-internal.h . When I try to compile subTest.cpp from the terminal, it says

g++ sumTest.cpp In file included from sumTest.cpp:1: ./gtest/gtest.h:62:10: fatal error: 'gtest/internal/gtest-internal.h' file not found #include "gtest/internal/gtest-internal.h" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

So it finds the file gtest/gtest.h but not the file gtest/internal/gtest-internal.h , which seems strange to me.

I'm thankful for every kind of help.

1
Thanks for your quick answer! So do I have to add that path to my list of include search paths?tcffm
It might be worthwhile to familiarize yourself with CMake or at least install googletest properly and configure the include/lib paths for your project.rustyx

1 Answers

1
votes

The line with your error is the first local include statement in gtest.h. The directory that contains gtest is not in your list of include search paths.

gtest/gtest.h is working only because it's relative to the current file.

You need to add the path that contains the directory gtest to your list of include search paths.