Tuesday, February 22, 2011

Setup OpenGL(glut) in code::block

TO create OpenGL/GLUT Project in code::block,at first you have to download the glut libary from this website http://code.google.com/p/rawvideoplayer/downloads/detail?name=glut-3.7.6-bin.zip&can=2&q= for windows.

Lets create GLUT project
step 1:

first unzip the zip file
step 2:
copy the glut.h file from the include folder of unzip file of step 1
and paste to the folder "C:\Program Files\CodeBlocks\MinGW\include\GL"
again copy all file from the lib folder of unzip file of step 1
and paste to the folder "C:\Program Files\CodeBlocks\MinGW\lib"
also copy the glut.dll file from the bin folder of unzip file and paste it
inside "C:\Windows\System32" floder.

step 3:
Open the code block you will see window as below and click on create new
porject link

step 4:
click on GLUT project as shown in image below
click next
Enter project title name ,give path to save project and project file name is created by default from project title name.
After that click next.

step 5:
now give the path "C:\Program Files\CodeBlocks\MinGW" for glut location

Then click next.

Now click finish

step 6:

Finally project is created and you will get default main.cpp file and don't forget to write  "#include<windows.h>" header file otherwise you will get error now built and run it will see window as below.

If you see the output of your program as above image then you have successfully 
created a project.


  1. Hi, do you have tutorial on setting up GLEW/GLFW/FreeGLUT, all three including the linking in Code::Blocks? I am having hard time setting it up. I found this good tutorial: http://www.arcsynthesis.org/gltut/index.html. I am getting this error when running the program (the aforementioned tutorial has source code tutorials and I had to use premake4.exe to generate the Codeblocks .cpb (no problem here).

    Anyways, error I get:
    cannot find -lframework (for Release of build)
    cannot find -lframeworkD (for Debug of build)

    1. Sorry Iam unknown about GLEW/FreeGLUT. My university exam is comming and deadline of project submission so I havn't time to do little effort. But GLFW setup in Code::blocks you can find here.http://codeincodeblock.blogspot.com/2011/02/setup-glfw-project-in-codeblock.html

  2. Thanks very much, your illustration really help me.

  3. i didn't found bin folder nor the glut.dll...??

  4. it doesn't work for me btw..., something wrong with the glut header , help !

  5. Where is the .bin folder?

  6. when i try to build my project then divert to glut.h. plz help

    1. This comment has been removed by the author.

    2. include window.h at the top of the source file or include gl.h and glu.h

  7. "cannot find -lglut32 " what does this mean??

  8. am not able to open main.c file which is under source

  9. D:\CG PROJECTS\car Race\car.cpp|118|error: name lookup of 'y' changed for ISO 'for' scoping [-fpermissive]|

    guys i get this error for every grphics program i compile???!!! :(

  10. I am getting error in glut.h header file.what should i do?

  11. How to install OpenGL in Codeblocks in Ubuntu 14.04 ?

  12. Can we modify the shapes? Can we use this technique to create softwares like faceworx or blender?