gpt4 book ai didi

linux - 无法在 Linux(Ubuntu)上使用 glew.h

转载 作者:行者123 更新时间:2023-12-04 18:50:11 30 4
gpt4 key购买 nike

最近,我从 Windows 转到 Linux 并尝试学习 Udemy 类(class),该类(class)最初是在 Windows 上使用 Visual Studio 教授的。

我需要使用两个头文件 glfw3.h glew.h 在类中。

我可以导入 glfw3.h 并使用它就好了,但是 glew.h 函数显示一些错误。

我使用了代码 sudo apt-get install libglew-dev 获取库文件。但仍然会弹出错误。

代码:

    #include <GLFW/glfw3.h>
#include <GL/glew.h>

int main(void)
{}

错误消息:
In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:85:2: error: #error gl.h included before glew.h
#error gl.h included before glew.h
^~~~~

In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:16088:93: error: conflicting declaration
‘typedef void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, GLfloat*)’
LAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat*
params);
^

In file included from /usr/include/GL/gl.h:2055:0,
from /usr/include/GLFW/glfw3.h:171,
from Lesson01.cpp:1:
/usr/include/GL/glext.h:12070:25: note: previous declaration as
‘typedef void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, const
GLfloat*)’typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)
(GLenum pname, const GLfloat *params);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:16090:91: error: conflicting declaration
‘typedef void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, GLint*)’
(GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint*
params);
^

In file included from /usr/include/GL/gl.h:2055:0,
from /usr/include/GLFW/glfw3.h:171,
from Lesson01.cpp:1:
/usr/include/GL/glext.h:12072:25: note: previous declaration as
‘typedef void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, const
GLint*)’ typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)
(GLenum pname, const GLint *params);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

最佳答案

正如您的编译器所建议的,包含文件的顺序很重要:

error: #error gl.h included before glew.h

只需反转前两行:
#include <GL/glew.h>
#include <GLFW/glfw3.h>

int main(void)
{
return 0;
}

关于linux - 无法在 Linux(Ubuntu)上使用 glew.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59783044/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com