Undefined references using GLUT with MinGW Undefined references using GLUT with MinGW windows windows

Undefined references using GLUT with MinGW


At the top of the source file mycube.c you have to include

#include<windows.h>

or include

#include<GL/gl.h> or #include<GL/glu.h>

Then compile you code there will be no such type of error.


The glut library you downloaded was built for 32-bit programs. It looks like your MinGW is building for a 64-bit target, which uses different names than the 32-bit (and is incompatible anyway).

Try adding the -m32 option to get MinGW to builds a 32-bit program:

gcc -m32 -Wall -ofoo mycube.c -L"C:\MinGW\lib" -lglut32cu -lglu32 -lopengl32

Note that mt 64-bit MinGW compiler (gcc version 4.6.1 (tdm64-1) from http://tdm-gcc.tdragon.net/download) gives a small clue about this problem:

ld.exe: skipping incompatible .\glut32\lib/libglut32cu.a when searching for -lglut32culd.exe: cannot find -lglut32cu