glew.h 和 glext.h 之间不兼容的函数原型

Incompatible function prototypes between glew.h and glext.h

我正在尝试使用 glew.h 和 glext.h 编译一些代码。这是一个最小的例子:

#include <GL/glew.h>
//#include <GL/gl.h> // commenting it doesn't change anything
#include <GL/glext.h>

int main(){
    return 0;
}

由于不同的函数原型,我有 6 个编译时错误。第一个是:

In file included from main.cpp:3:0:
/usr/include/GL/glext.h:12306:105: error: conflicting declaration ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, const GLfloat*)’
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
                                                                                                         ^
In file included from main.cpp:1:0:
/usr/include/GL/glew.h:16092:28: note: previous declaration as ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, GLfloat*)’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

glew.h:16092:

typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);

glext.h:12306:

typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);

区别在于 * params.

的常量

我正在使用 Ubuntu 18.04.5 LTS,mesa 20.0.8、glew 2.0.0-5 和 gcc 7.5.0(我应该升级到 Ubuntu 20 吗?)。

I'm trying to compile some code using glew.h and glext.h.

不要那样做。这是两种不同的工具,它们都做同样的事情。它们不打算彼此兼容,并且预计两者都不能在彼此存在的情况下工作(在同一源文件中)。

您正在使用 GLEW,或者您正在通过 glext.h 手动加载函数指针。选一个。