Wednesday, April 14, 2010

How to use “FreeGLUT” on windows with MinGW and Qt Creator

GLUT has been a very popular light weight library for student and enter-level researchers for years, as its clear structure, not excluded I mean, small size and perfect connectivity with OpenGL. However, GLUT is not a free software and has not been maintained for a while, although I am not sure about the maintainability of GLUT, it has been same since I was an undergraduate and learn OpenGL first time. So FreeGLUT is another recommended option for GLUT people.
In recent days, I am trying to compile and program some code on Window with GCC/G++. My first idea is Cygwin, which is an total solution for GNU stuff on Windows. However, the problem is that Cygwin does not have a IDE for Qt development and you have to take care all of the make file and dependence. Instead, I think MinGW is an executable substitution. Qt Creator is based on MinGW and Qt library has been deployed on MinGW. So, comparing the problem caused by Qt on Cygwin and make file, I prefer to transplant FreeGLUT to MinGW!
Ok, let us begin the instruction! The installation of FreeGLUT is simple! As I mentioned, FreeGLUT is a light weighted, the package is small. Some kind hearted people has been compiled the source code and publish it on the web. Thanks for that! You may download a package called “” and unzip it. You gonna get two folders and a DLL( if you do not know what is DLL, forget about it)! Please copy the header files in “include/GL” to “include/GL”, which may under “C:\Qt\2010.02.1\mingw\”, and copy the lib files in “lib” to “C:\Qt\2010.02.1\mingw\lib”. Then you need to copy the “freeglut.dll” to system32, or sysWOW64, if you are using a 64 bit computer. The next step is configure Qt creator. Make sure that your PRO file has “QT += opengl” and “LIBS += libfreeglut”! That is all, enjoy the “Hello world” below!

If you want to know something about static linking or beyond, please chech this blog:


void keyboard(unsigned char key, int x, int y);
void display(void);

int main(int argc, char** argv)
glutInit(&argc, argv);
glutCreateWindow("GLUT Test");


void keyboard(unsigned char key, int x, int y)
switch (key)
case '\x1B':

void display()

glColor3f(1.0f, 0.0f, 0.0f);

glVertex2f(-0.5f, -0.5f);
glVertex2f( 0.5f, -0.5f);
glVertex2f( 0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);