1

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
BЈовић
  • 62,405
  • 41
  • 173
  • 273
zeboidlund
  • 9,731
  • 31
  • 118
  • 180

2 Answers2

0

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.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
0

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...

Bart
  • 19,692
  • 7
  • 68
  • 77