Tuesday, February 22, 2011

Setup OpenGL(glut) in code::block



Download the glut libary from website http://code.google.com/p/rawvideoplayer/downloads/detail?name=glut-3.7.6-bin.zip&can=2&q= for windows.

Steps to create glut project in Code::block.
Step 1: Extract the downloaded zip file.

Step 2: Browse extracted files. Copy the glut.h file and paste it into the directory "C:\ProgramFiles(x86)\CodeBlocks\MinGW\include\GL". Copy glut.lib file and paste it into the directory "C:\Program Files(x86)\CodeBlocks\MinGW\lib". Also copy the glut.dll and paste it into
the directory "C:\Windows\System32".


Step 3: Open the Code::block and click on create new project from Start page or go to File-> New-> Project from menu bar.
Step 4: Click on GLUT project as shown in image below and click Go button.
Enter necessary details and click Next button.

Step 5: Now provide path "C:\Program Files\CodeBlocks\MinGW" for glut location and click Next button.



Click Finish button.
Step 6:



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


If program execution failed showing glut32.dll not found then copy glut32.dll file in same directory
side by side with program execution file.

19 comments:

  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)

    ReplyDelete
    Replies
    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

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

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

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

    ReplyDelete
  5. Where is the .bin folder?

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

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

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

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

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

    ReplyDelete
  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???!!! :(

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

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

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

    ReplyDelete
  13. i am getting error
    C:\Program Files (x86)\CodeBlocks\MinGW\include\GL\freeglut_std.h|639|undefined reference to `_imp____glutCreateWindowWithExit@8'|

    ReplyDelete
    Replies
    1. ye saare mil ke humein chutiya bana rahe hai, gand fatti ke bhadwe madarchod

      Delete