decoration left 1
decoration left 2
decoration rigth

Show/Hide search bar
black cat logo variable logo
[1 Dec 2012]

Usage of GLEW with Qt + MinGW + Win7

For usage of GLEW library with Qt in combination with MinGW compiler and Window7 OS, it's required to create new .dll (there're no MinGW compatible dll on GLEW website). Download newest GLEW sources.

Run cmd.exe and set current directory to folder where GLEW sources are located. Then create dll with following commands:
gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c

gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

ar cr lib/libglew32.a src/glew.o

Now, lib folder contains new files. Place GLEW files in following folders (C:/MinGW part may be different):

  • libglew32.a and liglew32.dll.a files to C:/minGW/lib folder
  • glew32.dll file to C:/minGW/bin folder
  • .h files from include folder to C:/minGW/include/GL folder

Modify .pro file of your Qt project:
INCLUDEPATH += C:/MinGW/include/GL
LIBS += -lglew32 -LC:/MinGW/bin -LC:/MinGW/lib

Include GLEW header in files where additional OpenGL functionality is required. GLEW header must be included before all Qt's includes of OpenGL, like #include <QGLWidget>:
#include 'GL/glew.h'

Initialize OpenGL functions: // to properly initialize all available OpenGL function pointers
glewExperimental = GL_TRUE;
// place this in initializeGL()

You must provide glew32.dll with final version of your program.

Sun and Black Cat- Igor Dykhta (igor dykhta email) 2007-2014