I'm trying to compile an old OpenGL project using MinGW on Windows, but I'm running into linker errors for every OpenGL/GLUT function. My setup:
main.cpp includes:
#include <time.h>
#include <iostream>
#include <math.h>
#include <windows.h>
#include "glut.h"
In the same directory as main.cpp, I have:
- open32.dll
- glu32.dll
- glut32.dll (downloaded)
- glut.lib (downloaded)
- glut.h (downloaded)
- glut.def (not sure if needed)
In MinGW\include\GL I have:
- gl.h
- glu.h
- glext.h (These came with the MingGW installation)
Build command:
path %path%;C:\MinGW\bin
g++ -o program.exe main.cpp glut32.lib
Error example:
undefined reference to `glClearColor@16`
...and similar errors for all OpenGL and GLUT functions.
How do I correctly link OpenGL and GLUT with MinGW to resolve these undefined references? What libraries do I need to link, and in what order?