How to Download and Setup CodeBlocks on Windows (Including Graphics Files) : Step By Step High-Quality Guide

Setup CodeBlocks on Windows

In This Tutorial, We are gonna learn about the Installation Process of CodeBlocks on your PC with Windows, Mac, or Linux from beginning to end. So, before starting let’s talk about the Software which we are going to Install on our System?

A. Introduction of CodeBlocks

CodeBlocks is a free of cost open-source C, C++, and Other Fortran compiler for Windows, macOS, and Linux. CodeBlocks is a cross-platform, free IDE that helps GCC, Visual C++, and other compilers. Codeblocks were developed in C++ using wxWidgets for Windows and Linux as the GUI toolkit.

This software options an all-in-one installer that features the entire code libraries and tools you may want to start out coding. It options an easy-to-use interface and is a superb device for students or those that wish to be taught coding. It can also be expandable by using plugins, making it helpful for advanced users as nicely.

B. Download & Install CodeBlocks IDE

Don’t forget to follow these instructions carefully. Do NOT simply proceed without completely reading each step of the instructions carefully or you’ll probably not set up the software program accurately. So, Follow this Guide.

  • Visit the Official Website of CodeBlocks
  • Go to your Platform Downloading Section e.g., Windows, macOS, Linux, then download the installer of CodeBlocks, e.g., CodeBlocks-20.03-setup.exe, or Click here to download.

Download CodeBlocks


  • After Downloading the Setup Double-click to run the downloaded installer and click Next on the pop-up window. Now click on “I Agree” to accept the license agreement.

CodeBlocks Install 1Codeblocks install 2Codeblocks install 3

  • On the new pop-up, don’t do anything, just click Next and then change the installation directory if you want (default directory recommended) then simply Click Install.

Codeblocks install 4

  • Wait for a minute for the installation to complete.
  • A new pop-up asks you to run CodeBlocks Now. Click Yes or No, It depends on you.
  • Another pop-up will comes up then click on finish.
  • Finally, CodeBlocks is now Installed on your System.

C. Download & Install Compiler For CodeBlocks (Separately)

You need to install Compiler for the execution of the C, C++ Programs in CodeBlocks, and the second thing, you may run it by simply clicking it run, you might want to compile it first by clicking build or you can do each of these together by clicking “build and run”.

  • Download TDM-GCC Compiler(32 Bit) – Click Here
  • On the Downloading Page, You have to download the 32 Bit TDM-GCC Compiler

TDM-GCC Download

  • After Downloading the Installer of TDM-GCC click on the Installer.

TDM-GCC Install 1

  • Click on Create Option and Uncheck the Check for updated files box.

TDM install 2

  • Choose MinGW/TDM (32-Bit) and Click on Next.

TDM install 3

  • Here you have to select the destination (E.g. C:\\TDM-GCC) for the Installation of the compiler. Click on Browse the choose a Separate Folder for this Software and then click on Next.
  • After clicking on Next, A new pop-up will comes up then click on Install.
  • After clicking the Install Button the Compiler will start extracting the files and after one or two minutes the compiler will be installed on your system. Now let’s move to the next step.

D. Open CodeBlocks for the First Time

  • Launch CodeBlocks: To launch the program, double-click the CodeBlocks icon the installer placed on your desktop. If you do not have a desktop shortcut, the program might be found below Start–> All Programs —> Code::Blocks –> CodeBlocks.exe

Search Codeblocks

  • Launch the Program.

Codeblocks interface

  • Here you can see the Default Interface of the CodeBlocks Software.
  • To start writing the C, C++ program in code blocks Click on Create a new Project Option, as you can see in the above image.

Project in CodeBlocks

  • A new pop-up will comes up, here you have to choose the Project Type, So you have to click on the Console Application Option and click on Go.

Choose the Extension

  • Now you have to choose your Desired Language to be used in the application further. Let’s choose C++ and Click on Next.

  • In this option, you have to give a title to your project and the destination path where the files of your program will be saved. Then click on Next.

Now, we have successfully Installed, Configured the CodeBlocks IDE and the Compiler to Run the C, C++ Programs but What If we have to write and execute Graphics Program on CodeBlocks. We are unable to run the Graphics Code on CodeBlocks without having the Separate Graphics Files because there is no default file is available in the library of  CodeBlocks for compiling and executing the Graphics Codes.

If we will Compile any Graphics codes on CodeBlocks IDE shows an error: “Cannot find graphics.h”. This is because graphics.h runs aren’t out there within the library folder of CodeBlocks. To efficiently compile Graphics code on CodeBlocks, setup the winBGIm library. So, let’s move forward to the next process of Configuring the Graphics Files to execute the Graphics Program in CodeBlocks IDE.

E. Include Graphics Header Files in CodeBlocks

How to Include/Add Graphics.h in CodeBlocks? 

Please follow the below steps in sequence to include “graphics.h” in CodeBlocks to successfully compile graphics code on Codeblocks.

  • Step 1: To setup “graphics.h” in CodeBlocks, first set up the Graphics library.
  • Download the Graphics Header Files using this Link – Download Files
  • Step 2: Extract the downloaded file. There will be three files:
    • graphics.h
    • winbgim.h
    • libbgi.a
    • Readme.txt (Inluding Steps of Installtion)

Graphics 1

  • Step 3: Copy and paste graphics.h and winbgim.h files into the include folder of compiler directory. (Means you have to Copy these files into the Folder of the TDM-GCC Compiler) If you have the TDM-GCC Compiler Installed in the C Drive Go through: Disk C > TDM-GCC-32> include. Paste these two files in the Include Folder of TDM-GCC-32).

Graphics File

Winbgim File

  • Step 4: Now Copy and paste libbgi.a to the lib folder of the compiler directory.

libbgi file

Step 5: Now, Open CodeBlocks. Go to Settings > Compiler > Linker settings.

Compiler Setting

Linker Setting

Step 6: In the Linker option, click the Add button under the “Link libraries”, and browse.

Linker GCC

  • Step 7: Browse the Directory of the Compiler (C>TDM-GCC32>LIB>libbgi.a) Select the libbgi.a file and click on OK.

(I have already linked the library that’s why the path is visible but in your case, the “Link Libraries” section will be empty and when you will add the library it will add the destination path in the “Link Libraries” section as you can see in the above image).

  • Step 8: In the right section “Other Linker Options” paste this command carefully.( -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 )

other linker option in GCC

  • Step 9: Click OK

Now Let’s Create a Graphics.h Program in CodeBlocks

  1. To create your first Graphics program, Write the code into CodeBlocks. including (graphics.h) header file.

Graphics Program

2. For Example I have written a code to build a Circle.

3. After writing the code click on the “Build and Run” option to Run the Program on CodeBlocks.

Build and Run in CodeBlocks

4. After running, a terminal window will pop up with the “Circle”. The execution time will vary based on the speed of your computer. So In this way, you can Write and Execute Graphics Program on CodeBlocks.

Some Important Points Only If you are facing any Kind of Error

  • If you are trying to compile a graphics.h program in C or C++, and if you are facing any error there then you have to make some changes. To solve the issue, open graphics.h file (pasted in include folder) with Notepad++ or Notepad(Run as Administrator). Go to line number 302, and replace that line with this line : int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX, 

After that save the file and the issue will be solved.

  • Now, If you are facing any different kind of error saying “fatal error: sstream : no such file directory” then you have to change your file extension to .CPP If it is .C

So here is the Installation Process of CodeBlocks, Hope you liked this post.

Thanks for Reading!😊 Don’t forget to share because ‘Sharing is Caring’.

Also Read: IOS 15 Release Date in India


Please enter your comment!
Please enter your name here