Qt Creator 中的 Glew 链接问题?

发布于 2024-12-28 17:18:44 字数 1474 浏览 2 评论 0原文

我试图通过 QMake 文件在 Qt Creator 中链接 GLEW(与 SDL 和 OpenGL - 注意,不是 SDL 的 OpenGL 实现),尽管我运气不佳。无论我尝试什么,我似乎都会遇到相同的字符串错误,这些错误处理源自一些 typedef冲突声明问题。我想知道为什么会发生这种情况,以及可以采取什么措施。

示例

/usr/include/SDL/SDL_opengl.h:4855: error: conflicting declaration ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, const GLfloat*)’
/usr/include/GL/glew.h:12201: error: ‘PFNGLFRAGMENTLIGHTFVSGIXPROC’ has a previous declaration as ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, GLfloat*)’

这是因为我正在与 SDL 链接(看看它如何支持 OpenGL),还是这里还有其他原因?

Qmake 文件

QT += core

LIBS += -lSDL -lSDL_image -lopengl32 -lGLU -lGLEW

stdafx.h

#pragma once

/*************/
/* #includes */
/*************/

//GL / SDL
#include <GL/glew.h>
#define GLEW_STATIC
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>

//STD
#include <iostream>
#include <fstream>

//Qt
#include <QListIterator>
#include <QMapIterator>
#include <QVector4D>
#include <QColor>

/********************/
/* Using Statements */
/********************/

using std::cout;
using std::endl;
using std::cin;

using std::fstream;

stdafx.cpp

#define GL_GLEXT_PROTOTYPES

I'm trying to link GLEW (with SDL and OpenGL - note, not SDL's implementation of OpenGL) in Qt Creator via a QMake file, though I'm not having much luck. No matter what I try, I seem to get the same string errors which deals with conflicting declaration problems stemming from a few typedefs. What I'd like to know is why this is happening, along with what can be done about it.

Example

/usr/include/SDL/SDL_opengl.h:4855: error: conflicting declaration ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, const GLfloat*)’
/usr/include/GL/glew.h:12201: error: ‘PFNGLFRAGMENTLIGHTFVSGIXPROC’ has a previous declaration as ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, GLfloat*)’

Is this because I'm linking with SDL (seeing as how it has OpenGL support), or is there something else going on here?

Qmake File

QT += core

LIBS += -lSDL -lSDL_image -lopengl32 -lGLU -lGLEW

stdafx.h

#pragma once

/*************/
/* #includes */
/*************/

//GL / SDL
#include <GL/glew.h>
#define GLEW_STATIC
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>

//STD
#include <iostream>
#include <fstream>

//Qt
#include <QListIterator>
#include <QMapIterator>
#include <QVector4D>
#include <QColor>

/********************/
/* Using Statements */
/********************/

using std::cout;
using std::endl;
using std::cin;

using std::fstream;

stdafx.cpp

#define GL_GLEXT_PROTOTYPES

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2025-01-04 17:18:44

解决您问题的唯一方法是不使用其中之一(GLEW 或 SDL_opengl),或者至少不要同时包含 GL/glew.hSDL/SDL_opengl.h 任何源文件或头文件中的标头。

The only solution to your problem is not to use one (either GLEW, or SDL_opengl), or at least do not include both GL/glew.h and SDL/SDL_opengl.h headers in any source or header file.

谢绝鈎搭 2025-01-04 17:18:44

我之前也遇到过类似的问题,我们通过在包含 之前定义 NO_SDL_GLEXT 来“解决”,所以:

#define NO_SDL_GLEXT
#include <SDL/SDL_opengl.h>

我说“已解决”,因为它使错误消失,但我从未调查过可能的副作用或问题(在那之后不久我们最终放弃了 SDL,并且再也没有真正使用过它)。也许值得一试...

I have had similar issues before which we "solved" by defining NO_SDL_GLEXT before the inclusion of <SDL/SDL_opengl.h>, so:

#define NO_SDL_GLEXT
#include <SDL/SDL_opengl.h>

I say "solved", because it made the errors go away, but I never investigated possible side-effects or problems (we ended up moving away from SDL shortly after that and never really used it anymore). Perhaps worth a try...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文