Saturday, October 27, 2012

OpenGL and freeglut on Linux + Codeblocks

Hey everyone,
After long time I'm writing on this blog. Hope to keep things up from here onwards but cant promise.

This post is about doing OpenGL programming in codeblocks.

Codeblocks is a C/CPP IDE. Usually opengl c programming is done in this. Our lecturer, Ms. G. S. Makalanda ( Senior Lecturer) B.Sc.(Math)(SL), M.Sc.(Stat)(SL), M.Sc. (Comp. Sci.)(UK),  has asked us to install code-blocks in order to do C programming on opengl. Well everyone except me is working on windows pc's. This is my story, problems, solutions I found to overcome to run code successfully on codeblocks.

Codeblocks was in Ubuntu Software center so no problem in installing it. I guess there was opengl installed in default. When I create new opengl project, the sample code runs smoothly. But when I create a new glut project it says,  
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glClear'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glColor3f'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glBegin'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glVertex3f'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glVertex3f'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glVertex3f'|
CG/gluttest.o:gluttest.c:function display: error||undefined reference to 'glVertex3f'|
*some more references like same*
||=== Build finished: 33 errors, 0 warnings ===|
 like wise gives build error for each gl function. Other guys on windows pc had the same problem but they seems to fix it when they changed glut library. So I did some search and found that I have to install freeglut (linux version of the glut).