How to configure Open GL for CodeBlocks?

OpenGL is one of the most popular graphics libraries for rendering 2D and 3D vector graphics. So, let’s begin configuring OpenGL for your system and remember this trick only work for 64-bit.

Step 1: Download this folder called “Open GL files” containing necessary files for our configuration.

Step 2: Extract the downloaded file.

Open GL file

Step 3: Open the extracted folder and go inside the “include” folder then copy all of it’s contents, after that go to your CodeBlocks installation directory(folder) and open “MinGW > include” , if you don’t have a folder called GL in there already, then create new folder called GL. For me it’s  “C:\Program Files(x86)\CodeBlocks\MinGW\include\GL”

Open GL file

Now, open the GL folder and paste the contents copied header files.

Open GL file location

Step 5: Again, open the extracted folder(from step2) and go inside “lib” and copy all of it’s contents, after that go to your CodeBlocks installation folder and open “MinGW > lib” then paste the copied “.glut “and “.a” files. For me it’s “C:\Program Files (x86)\CodeBlocks\MinGW\lib

Step 6: Again, open the extracted folder(from step2) and go inside “GLUT DLL”  folder and copy all of it’s content and paste it inside “C:\Windows\SysWOW64” (this is the most important part if done incorrectly you may get a missing glut.dll file error while compiling, thanks to Aayush Raut for finding out this trick to avoid missing glut.dll error).

Step 7: Open CodeBlocks and

  • Click on “setting > compiler”
Code Block setting
  • Now clock on “linker setting” and then, click on add
Code Block setting
  • Click on browse
  • Then, go to your CodeBlocks installation directory, and go to “CodeBlocks/MinGW\lib”. For me it’s “C:\Program Files (x86)\CodeBlocks\MinGW\lib” then, select glew32.lib, glew32s.lib, glut32.lib, libopengl32.a and then click open, after that click on ok and again click on ok
Code Block MinGW

Step 8: Now to check If OpenGL is set properly or not, open new project on code blocks by clicking on file > new > project

Code Block

Now select glut project and click go

Code block

Enter name of your project and click next

GLUT project

Now, click on those 3 horizontal dots and navigate to your CodeBlocks installation directory, open MinGW folder and click on “ok” then click on “next”

GLUT project

Now on your left-hand side you see management window with projects opened, click on your project and expand source, you can find main.c inside source, and then click build and run,

Code block project

if this screen appears then you’ve successfully configured OpenGL to work with CodeBlocks.

GLVT shape

Aadit Panta

I am a computer science undergraduate from Nepal.

Leave a Reply