HOWTO Use Mark J. Kilgard's OpenGL Utility Toolkit (GLUT) with MinGW

  • Download the binary and unpack the binary distribution of Nate Robins' Win32 port of GLUT. These instructions are based on version 3.7.6 and may not work with earlier or newer versions.
  • Create a subdirectory called GL in your project's include directory, and copy the file =glut.h= from the package there.
  • Copy the library, glut32.lib, to your project's build directory.
  • Copy the DLL, glut32.dll, to the same directory where your project's executable will be created.
  • Ensure that you're using binutils 2.16.91 or later.
  • Define the macros _STDCALL_SUPPORTED and _M_IX86 before including <GL/glut.h> in your source code. Three ways you can do this are:
    • on the command line with -D_STDCALL_SUPPORTED -D_M_IX86
    • use macro defintions in your source code (eg. #define _STDCALL_SUPPORTED)
    • include <windows.h> before including <GL/glut.h>
  • Compile your project, ensuring that <GL/glut.h> is in the include path, and that you're linking with glut32.lib.

When distributing any applications you built using GLUT, you need include a copy of glut32.dll in your distribution. This is not a standard Windows DLL so you can't expect your users to already have it installed on their systems. You should install glut32.dll in same directory as your application's executable. This ensures that other applications won't install a buggy or incompatible version of the GLUT DLL over yours.


Errors you may get:

E:\TEMP/ccwosggb.o:t10.c:(.text+0x1c): undefined reference to `__glutInitWithExit'
E:\TEMP/ccwosggb.o:t10.c:(.text+0x37): undefined reference to `__glutCreateWindowWithExit'
E:\TEMP/ccwosggb.o:t10.c:(.text+0x52): undefined reference to `__glutCreateMenuWithExit'
E:\TEMP/ccwosggb.o:t10.c:(.text+0x15a): undefined reference to `glutDisplayFunc'
E:\TEMP/ccwosggb.o:t10.c:(.text+0x15f): undefined reference to `glutMainLoop'
...

This indicates that you didn't define _STDCALL_SUPPORTED before including <GL/glut.h>. See the instructions above on different ways you can do this.

E:\TEMP/ccMMoggb.o(.text+0x1c):t10.c: undefined reference to `__glutInitWithExit@12'
E:\TEMP/ccMMoggb.o(.text+0x3e):t10.c: undefined reference to `__glutCreateWindowWithExit@8'
E:\TEMP/ccMMoggb.o(.text+0x60):t10.c: undefined reference to `__glutCreateMenuWithExit@8'
E:\TEMP/ccMMoggb.o(.text+0x1a5):t10.c: undefined reference to `glutDisplayFunc@4'
E:\TEMP/ccMMoggb.o(.text+0x1ad):t10.c: undefined reference to `glutMainLoop@0'
...

This indicates you're using an older version of binutils. Upgrade to 2.16.91.

E:\TEMP/ccMMoggb.o(.text+0x1c):t10.c: undefined reference to `__glutInitWithExit@12'
E:\TEMP/ccMMoggb.o(.text+0x3e):t10.c: undefined reference to `__glutCreateWindowWithExit@8'
E:\TEMP/ccMMoggb.o(.text+0x60):t10.c: undefined reference to `__glutCreateMenuWithExit@8'

If these are the only three undefined references then you probably linked with -lglut32 instead of glut32.lib.

./GL/glut.h:58: warning: ignoring #pragma comment
./GL/glut.h:66: warning: ignoring #pragma comment
./GL/glut.h:67: warning: ignoring #pragma comment
./GL/glut.h:68: warning: ignoring #pragma comment
./GL/glut.h:76: warning: ignoring #pragma warning
./GL/glut.h:77: warning: ignoring #pragma warning

These warnings are harmless, but you can define the macros GLUT_NO_LIB_PRAGMA and GLUT_NO_WARNING_DISABLE before including <GL/glut.h> to prevent them.

./GL/glut.h:549: warning: 'glutCreateMenu_ATEXIT_HACK' defined but not used

This warning is also harmless, but I'm not sure of any safe way to prevent it without modifying =<GL/glut.h>=.

procedure entry point could not be located in dll

Perhaps this can help someone who had a similar problem. I was trying to call the DevIL libraries though.

(Under XP) If you are trying to call a library / dll from c++ / mingw and you get the
runtime error, "procedure entry point could not be located in .... .dll", recreate the .a files using dlltool
in this way.

dlltool -k -D DevIL.dll -d DevIL.def -l libDevIL.a
do the same for all dll's.

The other syntax for dlltool does not seem to work (you get the error above).

I hope this helps someone.

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC