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):


//Drawing funciton
void draw(void)
  //Background color
  //Draw order

//Main program
int main(int argc, char **argv)
  glutInit(&argc, argv);
  //Simple buffer
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
  glutCreateWindow("Green window");
  //Call to the drawing function
  return 0;

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

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


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

One thought on “Installing OpenGL Development Environment in Ubuntu

  1. Or, you can use following Makefile (linux/mac):

    CC = g++
    CFLAGS = -Wall
    PROG = test

    SRCS = main.cpp

    LIBS = -lglut -lGLU

    all: $(PROG)

    $(PROG): $(SRCS)
    $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)

    rm -f $(PROG)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s