CODE : : BLOCK, An Open Source IDE For C/C++ Programming

Today, we have many IDEs that convert the routine task of writing thousands of lines of code into a meaningful process. IDEs are a smart productive tool to increase the efficiency of the developer. Moreover, they are a combination of editor, compiler and debugger, intelligent enough to identify and auto-complete syntax and typical keywords. Hence, Code::Block also leverages software development with a smart IDE. It is an open source, free programing environment especially designed for C, C++, and FORTRAN. The first stable version of of Code::Blocks was version 8.02 in 2008. It supports a variety compilers, including Microsoft C++, Borland, Intel C++, and GCC. However, Code::Block is also available on Linux and the MAC platform, but this article especially deals with Code::Block for the Windows platform.


As said earlier, Code::Block is an open source programming environment. Hence, it has binaries for Windows, Linux and Mac platforms that can be downloaded freely from its official website without paying a single penny. Identifying the correct package is the first essential task because there are distinct packages available, leveraging dispersed features for both Windows and Linux platforms.

                                    Figure 1: Choosing installation package

Once we have downloaded the correct package, its installation is quite easy on Windows as is typical for other software. Finally, the Code::Block development environment window will look such as:

                                    Figure 2: Code::Block IDE's First view

Code::Block in Action

After doing the installation and subsidiary configuration, it's time to proceed with the coding. You will observe that a screen appears right after imitating this software like in Figure 1 that enables the developer to create a new project and other things.

To start a new project click "Create New Project" on the screen. Here, you will get a huge list of predefined project templates as in Figure 3. For this article, we will proceed with the “Console Application” that allows you to write a console program.


console application
                                    Figure 3: Step-1

The other applications are for developing more advanced types of applications. After selecting Console application, click on the Go button to begin using the Console Application Wizard. Henceforth, the wizard will ask to choose the programming language between C and C++ for coding such as shown in the following Figure 4.

                                          Figure 4: Step-2

Later, it prompts to specify the project name along with its directory location to store and select the default compiler as GNU that the IDE detects automatically as in screenshot 5 and 6 respectively.

project name along with its directory

Since we have choose C++ as the programming code language, there is a file called main.cpp with default “Hello Word!” code automatically generated in the solution as shown in Figure 7. Here after we can debug and compile this code with the F9 key. After compilation, if there is any error in the arbitrary code, the IDE will reflect a visual indication like in other IDEs.

cpp file default code
                                    Figure 7: main.cpp file default code

Since that is generated automatically, the following code sample is therefore providing a real experience in C++ coding with the Code Block IDE in which we are calculating a Fahrenheit value from Centigrade as in the following.

  1. #include <iostream>  
  3. using namespace std;  
  5. int main()  
  6. {  
  7.     float c = 50;  
  8.     float f = (c * 9 / 5) + 30;  
  10.     cout << "Calculated value of F=" << f << endl;  
  11.     return 0;  
  12. }  
Listing 1: Centigrade to Fahrenheit conversion code

After successfully compiling and debugging the program, it produces the calculated Fahrenheit value along with other variables including execution time in the console windows as in the following:

                                          Output: Calculated value of Fahrenheit

Essential Configuration

As we claimed in the earlier paragraph that Code::Block supports numerous compilers, since we have choose the GNU GCC compiler in this article we can do the necessary configuration for that compiler. This optional setting aid while the program faces some unexpected errors that occurr during the execution related to the linker, compiler, build options and directories setting. We therefore, can fix such glitches using this dialog box that can be accessed using the Setting | Compiler menu as in the following:

Compiler Settings
                                                   Figure 8: Compiler Settings

Moreover, if you have a project with additional existing files, go to the Project menu and select “Add files.” This will bring in the files associated with your program. By clicking on Add files to project, that will bring up a window so you can browse to where your files are that you wish to add. Select any additional file you want to add and press Open. The file will then be added to your project.

Besides, we can use the build option to ensure that Debug is running, you can use the Project pull-down menu and click on Build Options. Here, ensure that the Produce debugging symbols [-g] is checked as in the following:

Debug Settings

                                                      Figure 9: Debug Settings


This article provided an alternative approach to coding C/C++ programming under a different arena by introducing an open source IDE Code::Block that endorses a wide range of renowned compilers. However, the contents in this article are Windows-centric but everthing is quite similar on Linux and Mac too. Here, we have briefly touched on some of the essential features of Code::Block that might be conducive for developers in terms of improving the efficiency while coding. Moreover, the code::block offers a variety of plug-ins and other substantial features to prompt FORTRAN and assembly language.