Computer Programming web Web programming Tips



How to use the CodeBlocks open source compiler for a C++ project

By Sergey Skudaev


Download Code Blocks binaries: http://www.codeblocks.org/downloads/binaries.

Select the "codeblocks-16.01mingw-setup.exe" link to download executable with the GCC/G++ compiler and GDB debugger from TDM-GCC. There is an instruction for the installation, so you should not have any problems.

Let us create the same application using Code Blocks open source IDE. When you start the Code blocks application the window below is displayed.

CodeBlocks C++

Figure 12. The Code::Blocks IDE.

Click Create a new project link. On the next window select the Console application and click the Go button.

CodeBlocks C++

Figure 13. Select a project type.

The console application window is displayed with options for C and C++.

CodeBlocks C++

Figure 14. Select C++ and click the Next button.

CodeBlocks C++

Figure 15. Enter project name, select a blank tree folder.

Click the Next button. Select a GNU GCC Compiler in the compiler drop down list and click the Finish button. See Figure 16.

CodeBlocks C++

Figure 16. Selecting a Compiler.

The project is created. Select the project and open the main.cpp file.

CodeBlocks C++

Figure 17. A simple console application.

Enter a code the same as the code in Figure 18.

CodeBlocks C++

Figure 18. A simple C++ program that draws a tree.

Save the file by clicking the Save icon on the main tool bar.

CodeBlocks C++

Figure 19. Run the program.

From the main menu select Debug, Start and your code will be compiled.

CodeBlocks C++

Figure 20. The Tree program output.

Click Yes to agree to rebuild the project. The bottom of the window will display errors if any. Now you know how to use Code Blocks IDE.

My eBooks on Amazon.com

US    UK    BR    CA
US    UK    BR    CA
US   UK   BR   CA