GLFW/glfw3.h: No such file or directory

I am trying to learn glfw and opengl but I got the error that i mentioned on the title that is no such file or directory.

cmake:
cmake_minimum_required(VERSION 3.30.3)
project(cpp)
add_executable(cpp main.cpp)
target_include_directories(cpp PRIVATE dependencies)
cpp
#include <iostream>
#include <GLFW/glfw3.h>
using namespace std;
int main(){
    GLFWwindow* window;
    while (!glfwInit){
        cout << "hello";
    }
    window = glfwCreateWindow(800, 400, "hello", NULL, NULL);
    return 0;
}
cpp/
│
├── .vscode/
│   ├── launch.json
│   ├── tasks.json
│
├── build/
│   ├── CMakeFiles/
│   ├── cmake_install.cmake
│   ├── CMakeCache.txt
│   ├── compile_commands.json
│
├── Makefile
│
├── dependencies/
│   ├── GLFW/
│       ├── glfw3.h
│       ├── glfw3native.h
│
├── CMakeLists.txt
├── main.cpp
└── main.exe

Looking at what you have here, I’d say that GLFW headers should have been discovered, so I got curious and tried to reproduce your problem, but I could not (with CMake 3.29.2). The project of course fails on linking, because you are missing linking to GLFW binary, but I did not get your error about the header.

So it is probably something environmental, such as you are on a case-sensitive filesystem, and your GLFW headers folder is actually named glfw.

If you want, I could try to reproduce it with your exact project files, so if you’d be interested in that, share an archive or repository here.

this is the link to my project! Have a llok at it to see the details. I am bad at explaining.

Okay, I tried to reproduce the headers problem with the project from your repository, but it’s the same as the one that I tried to re-create based on your original description, so I did not get that error still.

Just in case, here are the commands that I executed:

$ git clone git@github.com:DPthang411/OpenglLearning.git
$ cd ./OpenglLearning/
$ git switch master
$ cd ./build/
$ rm -r ./*; rm -r .cmake; ls -lah
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
$ cmake --build .

and that resulted in:

[2/2] Linking CXX executable cpp
FAILED: cpp
Undefined symbols for architecture arm64:
  "_glfwCreateWindow", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture arm64

Like I already said, the linking error is expected, because you don’t link to GLFW in your project. But why you get the headers error - that I don’t understand. The only difference I can immediately see between our environments is that I’m on Mac OS and you seem to be on Windows (with MSYS/MinGW?), although that shouldn’t matter.

Just in case, I tried on Windows too, but got the same result:

main.cpp.obj : error LNK2019: unresolved external symbol glfwCreateWindow referenced in function main
cpp.exe : fatal error LNK1120: 1 unresolved externals

No error about headers.

wdym by i didnt libk it? i linked it using cmake?

I don’t see a single target_link_libraries() in your project.
So then what do you mean by “i linked it”? Can you show the exact line/fragment which you think does the linking in your project?