Я пытаюсь использовать платформу Google Test: https://github.com/google/googletest/tree/master/googletest.makefile: путь указан после -I, но файл заголовка не найден
У меня есть 4 файла:
factorial.cpp:
#include "factorial.h"
int factorial(int n) { [some code here] }
facotrial.h:
int factorial(int n);
test_factorial.cpp
#include "gtest/gtest.h"
#include "factorial.h"
[some tests here]
gtest_main.cpp:
#include <stdio.h>
#include "gtest/gtest.h"
GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from gtest_main.cc\n");
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Также у меня есть Makefile, который содержит (помимо всего прочего):
INCLUDES = -I/home/my_username/Documents/gtest/googletest/googletest/include
[...]
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)
После написания make
в терминале я получаю:
test_factorial.cpp:1:25: fatal error: gtest/gtest.h: No such file or directory
compilation terminated.
makefile:27: recipe for target 'test_factorial.o' failed
В чем проблема?
В файле README на googletest они говорят:
g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \
-o your_test
Так вот это -isystem
вместо -I
, но у меня были проблемы с -isystem, а также.