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.
Step-2: Select the application type as a console application and click on Go.
Step- 3: Then Click on “NEXT”.
Step-4: In the next window, select C as your language and click on next.
Step-5: Give a meaningful Project Name and select the folder where you want to create the Project.
Step-6: Then Click “FINISH”
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”.
Step-2: Write your first Hello World Program in the editor.
Step-3: Click on “Build and Run” in the top menu bar.
We have successfully 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.
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”.
Step-3: Click on “Settings” in the top menu bar and select Debugger.
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”.
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.
In the next article, we will understand the Basic syntax of the 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.