GLEW 给出了一堆未处理的错误

GLEW giving bunch of uncoused errors

我正在尝试学习 GLFW,我在网上找到了一个很好的教程。 我做了他们所做的一切,但是当我什至尝试向 main() 编写一行代码时,出现了很多错误。

给出的前两个错误是

In file included from main.cpp:10:0:
/usr/include/GL/glew.h:15769:109: error: conflicting declaration ‘typedef void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum, const GLint*)’
 typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data);
                                                                                                             ^
In file included from /usr/include/GL/gl.h:2055:0,
                 from /usr/include/GLFW/glfw3.h:153,
                 from main.cpp:7:
/usr/include/GL/glext.h:11616:25: note: previous declaration as ‘typedef void (* PFNGLGETFRAGMENTMATERIALIVSGIXPROC)(GLenum, GLenum, GLint*)’
 typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
                         ^

后面有很多看起来像

的错误
In file included from main.cpp:10:0:
/usr/include/GL/glew.h:16432:17: error: ‘PFNGLCLIENTACTIVETEXTUREPROC’ does not name a type
 GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;
                 ^

由于错误较多,我将它们粘贴到pastebin中: here

我的代码是:

#include <iostream>
#include <GLFW/glfw.h>
#include <GL/glew.h>
 
int main()
{
    return 0;
}

我使用这个命令编译它:

g++ -o exec main.cpp -I/usr/include/libdrm -lglfw -I/usr/include/libdrm -lGL -I/usr/include/libdrm -lGLEW -lGLU

我已经安装了所有东西,我可以在没有 glew 的情况下创建 GLFW 程序,但是 glew 似乎是导致这些问题的原因。

谢谢!

编辑: 如果重要的话,我使用 Ubuntu。

来自 http://glew.sourceforge.net/install.html

Also, GLEW will warn you by issuing a preprocessor error in case you have included gl.h, glext.h, or glATI.h before glew.h.

我怀疑 #include <GLFW/glfw.h> 在内部做了其中一件事情。尝试交换包含。


GLFW 确认:http://www.glfw.org/docs/3.0/build.html

If you are using an OpenGL extension loading library such as GLEW, the GLEW header should also be included before* the GLFW one. The GLEW header defines macros that disable any OpenGL header that the GLFW header includes and GLEW will work as expected.