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 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”
Now, open the GL folder and paste the contents copied header files.
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”
- Now clock on “linker setting” and then, click on add
- 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
Step 8: Now to check If OpenGL is set properly or not, open new project on code blocks by clicking on file > new > project
Now select glut project and click go
Enter name of your project and click next
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”
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,
if this screen appears then you’ve successfully configured OpenGL to work with CodeBlocks.