Skip to content
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

Open
jonben3215 opened this issue Nov 20, 2024 · 2 comments
Open

[Bug]: fatal error: gtest/gtest.h: No such file or directory #4664

jonben3215 opened this issue Nov 20, 2024 · 2 comments

Comments

@jonben3215
Copy link

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

@pgawro
Copy link
Contributor

pgawro commented Nov 20, 2024

Seems this is not a bug bur @jonben3215 perhaps you forget to add line in cmake like this find_library(GTest gtest) for did you forget to enable C++17 for your project. Could you pass output from command line when you try to configure your project or build?

@jonben3215
Copy link
Author

jonben3215 commented Nov 20, 2024

How do I access CMake so that I need to add the find_library(GTest gtest)? I failed to mention that I am running my code using g++ -std=c++<version> <.cpp> -o <exe name>. I am currently not running any cmake until later down my project. In addition I have also made sure that all gtest includes and libs are all present in my MSYS2 folders where MinGW64 is, but it seems to fail.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants