How to compile a program written in OpenGL
g++ -Wall -O my-program.cpp -lglut -o my-program
- -Wall: is a way of saying the compiler that it should output all the warnings
- -O: says the compiler to use some optimization techniques
- -l is a linker option stating to include the library followed the -l. Here is glut.
There is a little extra advantage when using GLUT, if you were developing an OpenGL application you should include the header files gl.h and glu.h (glu is the OpenGL Utility Library) but when you are including glut.h, glut.h guarantees the inclusion of gl.h and glu.h. So when we start and OpenGL application we start by writing:
- -o: says the compiler that it should produce a binary file whose name is my-program