我的代码如下所示:
#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);
我执行的命令是这样的:
g++ /home/user/git/tfg_gui/test.cpp -o /home/user/git/tfg_gui/test -I/home/user/git/tfg_gui/include
我的文件夹如下所示:
.
├── include
│ ├── glad
│ │ └── glad.h
│ ├── GLFW
│ │ ├── glfw3.h
│ │ └── glfw3native.h
│ └── KHR
│ └── khrplatform.h
├── test
└── test.cpp
编译器错误是:
/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.
我认为我犯了一个非常愚蠢的错误,但是我已经花了太多时间试图找到它。可能是因为我假设做某事的方式不正确。
谢谢!
在路径中,#include
您使用反斜杠\
:
#include <GLFW\glfw3.h>
在Linux或macOS之类的POSIX系统上,这不是有效的路径分隔符,而是被视为文件名的一部分。
您需要/
在以下系统上使用正斜杠:
#include <GLFW/glfw3.h>
由于正斜杠在Windows上也可以使用,因此始终使用它是一个好习惯。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句