undefined reference to `gluLookAt` How to fix in MinGW on Windows

The first step to play with OpenGL on MinGW and Windows is add GLUT support, the old GLUT is not maintained anymore, the best choice is use its newest implementation FreeGLUT. The most useful thing provided by this library is window control functions like glutCreateWindow and other primitive tools to get you started. To use it with MinGW see this MinGW Freeglut 64bit on Windows Example.

GLU is the OpenGL Utility Library. It is a set of functions to create texture mipmaps from a base image, map coordinates between screen and object space, and draw quadric surfaces and NURBS. GLU 1.2 is the version of GLU that goes with OpenGL 1.1.

The function gluLookAt is defined in GLU library. If you Fortunately, the MinGW integrate it in the distribution package, so you don't have to search and download the header files and library binaries. In my environemnt, the GLU is located at E:\MinGW\x86_64-w64-mingw32\include\GL and E:\MinGW\x86_64-w64-mingw32\lib.

You can directly use GLU by include the header files:

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

It will compile, but to link the library you need to explicitly tell the compiler to link to it, for compiler, you should add -lopengl32 -lglu32. For example

Notice these the names are used in Windows, in other platforms, you may need to use something like -lGL -lGLU instead.