Creating a new project using CodeBlocks IDE C Programming

Creating a new project using CodeBlocks IDE

In this article, I am going to discuss Creating a new project using the CodeBlocks IDE. Please read our previous article where we discussed how to download and Install the Codeblocks IDE Setup in Windows for C Program Development. At the end of this article, you will understand how to create a c program, debug, compile, and run using CodeBlocks IDE.

How to create a new project using the CodeBlocks IDE?

Step-1: Open CodeBlocks IDE and click on File > New > Project.

Open CodeBlocks IDE

Step-2: Select the application type as a console application and click on Go.

Creating a new project using CodeBlocks IDE

Step- 3: Then Click on “NEXT”.

How to create a new project using the CodeBlocks IDE

Step-4: In the next window, select C as your language and click on next.

select C as your language

Step-5: Give a meaningful Project Name and select the folder where you want to create the Project.

Give a meaningful Project Name and select the folder where you want to create the Project

Step-6: Then Click “FINISH”

Creating a new project using CodeBlocks IDE

Finally, we have created a C project in CodeBlocks IDE.

How to Code and Compile the code?

Step-1: In the left side panel, click on the project name to expand the project tree and click on “Sources > main.c”.

How to Code and Compile the code

Step-2: Write your first Hello World Program in the editor.

Write your first Hello World Program in the editor

Step-3: Click on “Build and Run” in the top menu bar.

Click on “Build and Run” in the top menu bar

We have successfully created, compiled, and executed the C program in CodeBlocks IDE.

Output:
created, compiled, and executed the C program in CodeBlocks IDE
How to Configure the GNU Compiler and Debugger?

Step-1: Click on “Settings” in the top menu bar and select Compiler. 

How to Configure the GNU Compiler and Debugger

Step-2: Go to the “Settings” menu ⇒ “Compiler…” ⇒ In “Selected Compiler”, choose the “GNU GCC Compiler” ⇒ Select tab “Toolchain Executables” ⇒ Check the “Compiler’s Installation Directory”. It shall be set to the “MinGW” sub-directory of the CodeBlocks installation directory, for example, suppose that CodeBlocks is installed in “c:\Program Files\codeblocks”, set it to “c:\Program Files\codeblocks\MinGW”. Then click “OK”.

How to Configure the GNU Compiler and Debugger

Step-3: Click on “Settings” in the top menu bar and select Debugger. 

Creating a new project using CodeBlocks IDE

Step-4: Similarly, check the debugger’s path. Go to the “Settings” menu ⇒ “Debugger…” ⇒ Expand “GDB/CDB debugger” ⇒ Select “Default” ⇒ In “Executable path”, provide the full pathname of “gdb.exe”, for example, “c:\Program Files\codeblocks\MinGW\bin\gdb.exe”. Then click “OK”.

Debugger Settings in Codeblocks IDE
How to Debug the program?

Now if you see, there will be line numbers visible on the left side of the program. Just click right beside the line number you will see a red dot appeared at that point. That is known as the Breakpoint. Now the execution of the program will stop at this point if you compile and run it.

How to Debug the program
Follow Us On