Installing OpenGL Development Environment in Ubuntu

1. Download OpenGl liberies

sudo apt-get install freeglut3 freeglut3-dev
sudo apt-get install binutils-goldc
sudo apt-get install libglew1.5

2. Create a test file (test.c):

#include 

//Drawing funciton
void draw(void)
{
  //Background color
  glClearColor(0,1,0,1);
  glClear(GL_COLOR_BUFFER_BIT );
  //Draw order
  glFlush();
}

//Main program
int main(int argc, char **argv)
{
  glutInit(&argc, argv);
  //Simple buffer
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
  glutInitWindowPosition(50,25);
  glutInitWindowSize(500,250);
  glutCreateWindow("Green window");
  //Call to the drawing function
  glutDisplayFunc(draw);
  glutMainLoop();
  return 0;
}

3.Compile the file linking the OpenGL/Glut libraries:

gcc -lGL -lglut -lGL -lGLEW test.c -o test 

or

g++ -I/usr/include -L/usr/lib -lglut -lGL -lGLU -lGLEW 

4. Configuring with eclipse

  1. Donwload and ADD CDT plugin for eclipse. Download Link
  2. After installing CDT, go to eclipse’s Menu, Projects->Properties
    From leftside bar, Expand C/C++ General->Path & Symbols
  3. Go to libraries add this four lib one by one ( glut, GL,GLU, GLEW ) .
  4. Now try to build and compile your code