WARNING: This page is about how to build the older OpenGL Utility Toolkit (GLUT) Library last updated on November 8th, 2001, not the "newer" Free OpenGL Utility Toolkit (FreeGLUT) Library.
If you are just starting out (and not maintaining or porting from an older GLUT project), you should build FreeGLUT ... not the GLUT described below.
How To Build the OpenGL Utility Toolkit (GLUT) Library for Win32 using MinGW and MSYS
Downloads:
Outline:
Procedure:
Download and Install MinGW and MSYS
mingw-get-inst-20101030.exe
C:\MinGW
).
gcc
and g++
was installed.
Download and Unzip the GLUT-for-Win32 Source Code
~~~~TODO~~~~
http://www.xmission.com/~nate/glut.html
During the writing of this procedure, the following source code was used:
http://www.xmission.com/~nate/glut/glut-3.7.6-src.zip
Click here for detailed instructions on how to complete this step.
Download the Makefile
~~~~TODO~~~~
Right click the following link and save the file:
makefile
Save the makefile
to the root of the unzipped GLUT-for-Win32 folder (i.e. glut-3.7.6/
where the README
is located).
Click here for detailed instructions on how to complete this step.
Make Two Modifications to the GLUT-for-Win32 Source Code
Make the following modifications:
include/GL/glut.h
starting at line 12:
#ifdef __MINGW32__
#define APIENTRY __stdcall
#define CALLBACK __stdcall
#endif
lib/glut/win32_winproc.c
so that it reads:
//#include <crtdbg.h>
glut.h
and win32_winproc.c
should look like the following:
Make the GLUT for Win32
~~~~TODO~~~~
In the MinGW Shell (also known as MSYS), cd
to the root of the GLUT-for-Win32 folder (i.e. glut-3.7.6/
where the makefile
was saved).
make
mingw32-make
Install the GLUT for Win32
~~~~TODO~~~~
make install
mingw32-make install
Test the GLUT for Win32
~~~~TODO~~~~
make test
mingw32-make test
progs/mesademos/
. The following window will be produced:
Relevant gcc
and g++
Flags:
gcc -o filename.exe filename.c -mthreads [-march=cpu-type] [-O3] [-Wall] [-Wextra] [-Werror] [-Iinclude-path] [-Llibrary-path] -lglut32 [-lopengl32] [-lglu32] [-mwindows] [-enable-auto-import]
g++ -o filename.exe filename.cpp -mthreads [-std=c++0x] [-ftemplate-depth=n] [-march=cpu-type] [-O3] [-Wall] [-Wextra] [-Werror] [-Iinclude-path] [-Llibrary-path] -lglut32 [-lopengl32] [-lglu32] [-mwindows] [-enable-auto-import]
gcc
g++
-o filename.exe
filename.c
filename.cpp
-mthreads
-std=c++0x
-ftemplate-depth=n
-march=cpu-type
-march=native
enables all the instruction sets supported by the local machine's CPU; hence, the result might not run on different CPU types.-O3
-Wall
-Wextra
-Werror
-Iinclude-path
-Llibrary-path
-lglut32
-lopengl32
-lglu32
-mwindows
-enable-auto-import
Troubleshooting:
References: