-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: fatal error: gtest/gtest.h: No such file or directory #4664
Comments
Seems this is not a bug bur @jonben3215 perhaps you forget to add line in cmake like this |
How do I access CMake so that I need to add the However, when I paste my entire location of the gtest.h I get a different error saying another .h file is missing or can't be found. |
@jonben3215 If you are not using CMake as a build system you will need to tell GCC explicitly the directory that the Google Test headers are located in and the Google Test libraries to link against. E.g. you need to do this: g++ [other options] -I/path/to/includes -o your_program source1.cc [source2.cc ...] -lgtest -lgtest_main The If you are using CMake (recommended, build systems make building your code much easier), use # look for Google Test 1.12.0 for example (hard error if not found)
find_package(GTest 1.12.0 CONFIG REQUIRED)
# add your program + link against the CMake targets
add_executable(my_program source1.cc source2.cc) # etc.
target_link_libraries(my_program PRIVATE GTest::gtest GTest::gtest_main) If CMake can't find Google Test then try setting |
Describe the issue
I am using MSYS2 to run C++ and I tried every single thing. I looked up documentation for on MSYS2 to install gtest and all he toolchain and everything is present how ever VS and VSC both give the same error: fatal error: gtest/gtest.h: No such file or directory. Here is my code:
`// test.cpp
#include <gtest/gtest.h>
// A simple test case
TEST(SampleTest, AssertionTrue) {
EXPECT_TRUE(true);
}
`
I at this point I have no clue what is happening I tried everything I could look up to resolve this issue.
Steps to reproduce the problem
This is hard to recreate. I am running this the first time. Can't really re-create the problem.
What version of GoogleTest are you using?
Name : mingw-w64-x86_64-gtest
Version : 1.14.0-1
What operating system and version are you using?
Windows 11 version 23H2
What compiler and version are you using?
g++ (Rev3, Built by MSYS2 project) 13.2.0
What build system are you using?
cmake version 3.30.3
Additional context
No response
The text was updated successfully, but these errors were encountered: