google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.94k stars 10.16k forks source link

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

Open jonben3215 opened 1 week ago

jonben3215 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 usingg++ -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.