Reputation: 357
My code looks like this:
#include <GLFW\glfw3.h>
// define the function's prototype
typedef void (*GL_GENBUFFERS) (GLsizei, GLuint*);
// find the function and assign it to a function pointer
GL_GENBUFFERS glGenBuffers = (GL_GENBUFFERS)wglGetProcAddress("glGenBuffers");
// function can now be called as normal
unsigned int buffer;
glGenBuffers(1, &buffer);
And the command I execute is this one:
g++ /home/user/git/tfg_gui/test.cpp -o /home/user/git/tfg_gui/test -I/home/user/git/tfg_gui/include
My folders look like this:
.
├── include
│ ├── glad
│ │ └── glad.h
│ ├── GLFW
│ │ ├── glfw3.h
│ │ └── glfw3native.h
│ └── KHR
│ └── khrplatform.h
├── test
└── test.cpp
The compiler error is:
/home/user/git/tfg_gui/test.cpp:1:10: fatal error: GLFW\glfw3.h: No such file or directory
1 | #include <GLFW\glfw3.h>
| ^~~~~~~~~~~~~~
compilation terminated.
I think I am doing a really stupid mistake but I have already spent too much time trying to find it. Probably is that I am assuming that something is done in a way that is not the right one.
Thanks!
Upvotes: 0
Views: 75
Reputation: 59
You are using backslashes, convert them to forward slashes.
#include <GLFW/glfw3.h>
Backslashes are escape characters, they are ment to convert regular letters that are always avaliable on your keyboard ( n
, a
, etc. ) to special characters that you can't read nor see ( LF
, Beep
, etc. ).
In this case, the compiler sees the file name as GLFW[unkown-character]lfw3.h
, but that file doesn't exist. Thats the source of the error.
Upvotes: 0
Reputation: 409136
In the path for the #include
you use a backward slash \
:
#include <GLFW\glfw3.h>
On a POSIX system like Linux or macOS this is not a valid path-separator, instead it's considered part of the file-name.
You need to use forward slashes /
on such systems:
#include <GLFW/glfw3.h>
Since forward slashes also works on Windows, it's a good habit to always use it.
Upvotes: 2