Back to: Data Structures and Algorithms Tutorials
Code Blocks IDE: Download, Installation, Setup, and Development
In this article, I will show you, how to download and Install Code Blocks IDE, how to set it up, and how to use it. For practicing the C/C++ program or developing applications in C/C++, we need some idea where we can type the program and compile the programs. We also need a compiler. The IDE that we choose is Code blocks. Let us see, how to download and install code blocks.
How to download Code Blocks?
To download Code Blocks, open the browser and navigate to the below URL.
http://www.codeblocks.org/downloads
Once you navigate to the above URL, it will open the following page. Here in Downloads, we have three options i.e. binary release, source code, and retrieve source code from SVN (subversion).
Here, we will go with the binary release, so click on the Download the binary release option and once you click on the Download the binary release option it will open the below page. Here we have multiple options that are only set up a file or no setup zip file or MinGW set up or MinGW no set up, etc. Here, we need to select ‘MinGW setup’. This will download the compiler as well as IDE. So, click on the Sourceforge.net link which is appeared on the codeblocks-20.03mingw-setup.exe link as shown below.
Once you click on the Sourceforge.net link, it will go to the web site and start downloading. It will take some time to download the file. Once the download is completed and lets us installed it.
Installation of Code Blocks IDE
Open the codeblocks-20.03mingw-setup.exe by double-clicking on it which is open the below window. Here you simply need to click on the Next button.
Once you click on the Next button, it will open the License Agreement window, and here again, you simply need to click on the “I Agree” button as shown in the below image.
Once you click on the “I Agree” button, it will open the Choose Components window and again here we are going with the default settings, so simply click on the Next button as shown in the below image.
Once you click on the Next button, it will open the Choose Install Location window. Here, if you want you can change the location where you want to install the Code Blocks IDE. I am going with the default location and hence simply click the Install button as shown in the below image.
Once you click on the Install button, it will extract the files of IDE and Compiler and will take some time to install the Code Blocks IDE and Compiler on your machine. At the time of installation, it will ask do you want to run code block ide now, simply say No. Once the installation completed, you will the following window and simply click on the Finish button.
Open Code Blocks IDE:
Now open the code blocks ide. You will find one icon like below. Simply double click on it to open the code blocks.
Once you open the code Blocks IDE, you find the following window.
Before we start writing the programs, we have to make some settings and these are one-time settings. Let us see, what are the settings
Code Blocks IDE Settings:
We have to go to the ’menu’ and at the end, we will find the ‘settings’ option, select that one and go to the ‘compiler’ option from the context menu as shown below.
This will open the Global Compiler Settings window. Here, you can see the language selected is C++ 98, which is an older version as shown below in the compiler settings tab.
We should select the latest version. So, that we can use all the features that we’ll be talking about in this course. So, that is C++ 11. This is one of the settings that we have to change, otherwise, some of the features that we’ll be showing will not work
Then select the Toolchain executables tab. Here in the Resource Compiler, we have to select a compiler. So, click on the select link and if you scroll down, you will find something called GDB or GDB 32. Whatever you find select that one and open the file as shown below.
And then click on the OK button as shown below.
Code Blocks IDE Debugger Settings:
What is debugging and how to do debugging that we will see in our next article. Let see the debugging setting. Go to the setting menu and select the debugger option from the context menu as shown below.
Once you select the Debugger option from the context menu, it will open the below Debugger Settings window.
We have to enable the debugger, then only we will be able to debug the program. The debugger allows us to trace the program line by line.
Select default, then you have to select the ‘Executable path’ click and again select the same file gdb or gdb32 and click ok as shown below.
Creating New Project using Code Blocks IDE:
Now, we are ready with the environment setup and now we can use the code blocks for writing C/C++ programs. Now, we will see how to create a new project using code blocks and whatever the steps we are showing, you always follow those steps for creating a new project. For every program, it is better you create a new project. So, let us see how to create a new project.
Select File –> New –> Project option from the context menu to create a new project as shown below.
From the next window, select the project type as a console application and then click on the Go button as shown in the below image.
From the next screen, simply click on the Next button as shown below.
From the next screen select the language. Here, I am selecting the language as C++ and click the Next button as shown below.
From the next window, give a meaningful name to your Project and select the folder location where you want to create the Project as shown in the below image.
From the next window, simply click on the Finish button as shown below.
That’s it the project is created with the following structure.
Click on main.cpp and you will see some code already being written. You can also write your own code here. And you can also observe that iosteam header file is also included as well as the namespace is also included.
How to Run the Program using Code Blocks IDE?
Now, let us see how to run the above program. Simply go to the Build Menu and select the Build and run option from the context menu as shown below.
Once you select the Build => Build and run option, then it will build your project, compile and run the application and you will get the following output.
This is how we can download, installed, and use the Code Blocks IDE to develop C and C++ Applications. In the next article, I will show you how to debug the program using Code Blocks IDE. Here, in this article, I try to explain how to download, install and set up the code blocks ide for C and C++ program development.