Creating a new project using CodeBlocks IDE

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.

How to create a new project using CodeBlocks IDE?

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

how to create c program, debug, compile and run using CodeBlocks IDE

Step- 3: Then Click on “NEXT”.

how to create c program, debug, compile and run using CodeBlocks IDE

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

How to create a new project using CodeBlocks IDE?

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

how to create c program, debug, compile and run using CodeBlocks IDE

Step-6: Then Click “FINISH”

how to create c program, debug, compile and run 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.

How to Code and Compile the C Program?

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

How to Code and Compile the C Program using Codeblocks IDE?

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

Output :

How to use 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 in CodeBlocks IDE?

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

GNU Compiler and Debugger in CodeBlocks

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”.

Setting GNU Compiler and Debugger in CodeBlocks

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.

How to Debug the program?

In the next article, we will understand the Basic syntax of C Program in detail. Here, in this article, I try to explain How to create a c program, debug, compile, and run using CodeBlocks IDE. I hope you enjoy this article.

Leave a Reply

Your email address will not be published. Required fields are marked *