For installing OpenGL on Ubuntu, just execute the following command (like installing any other thing) in terminal : sudo apt-get install freeglut3-dev
g++ programFile.cpp -o program -lglut -lGLU -lGL
./program
where filename.c is the name of the file with which this program is saved.