Installing C
C Program in Code::Blocks — Download, Install, Run
On this page, you will learn step-by-step how to download Code::Blocks, install it, set up the compiler, write your first C program, compile it, and run it successfully.
Prerequisites
- Windows 10/11: Must be able to install with admin privileges.
- Internet: Required to download the Code::Blocks setup.
- Space: About 300MB of free disk space.
Tip: Choose the Code::Blocks version bundled with MinGW. It includes the GCC compiler automatically, making setup faster and easier.
Download Code::Blocks
- Go to the official website and open the Download section.
- Select the version named codeblocks-XX-setup.exe (mingw). This version includes the GNU GCC compiler.
- Download the setup file and save it in your Downloads folder.
Note: If you choose the without mingw version, you will need to install GCC separately using MinGW or MSYS2.
Install Code::Blocks
- Double-click on codeblocks-XX-mingw-setup.exe.
- In the setup wizard, click Next → I Agree → Next.
- Make sure MinGW Compiler is selected in the components list.
- Choose the installation location and click Install.
- After installation, check Launch Code::Blocks and click Finish.
Done: Code::Blocks will open. On first launch, if prompted to select the default compiler GNU GCC Compiler, click Yes.
Compiler Setup (if required)
- Menu: Settings → Compiler... → Selected compiler: GNU GCC Compiler.
- In the Toolchain executables tab, check that paths for gcc.exe, g++.exe, and make.exe are auto-detected.
- If not detected, click Auto-detect. If the issue persists, manually set the MinGW installation path.
Common error: “No compiler found.” Fix this by selecting GNU GCC Compiler and setting the MinGW path correctly.
Create a New Console Project
- Select File → New → Project....
- Choose Console application and click Go.
- Select C as the language → Next.
- Enter a Project title (e.g., FirstCProgram), choose a folder location → Next → Finish.
Tip: Code::Blocks automatically creates a main.c file. This is where you write your first C program.
Write Your First C Program
Open Sources → main.c in the project tree and paste the following code:
#include <stdio.h>
int main() {
printf("Hello, Welcome to C World\n");
return 0;
}
Save: Press Ctrl + S to save the file.
Compile and Run
- Click Build → Build (or press F9). If there are no errors, proceed to the next step.
- Click Run → Run (or press Ctrl + F10).
- In the console window, you will see: Hello, Welcome to C World
Fast Shortcuts
- Build: F9
- Run: Ctrl + F10
- Save: Ctrl + S
- Toggle comment: Ctrl + Shift + C
FAQ
Should I choose the MinGW version?
Yes. For beginners, the MinGW bundled version is best because GCC is ready immediately.
What is a Console Application?
It is an application that displays input and output in the command line (black window). This is ideal for learning programming in the beginning.
Code::Blocks on macOS / Ubuntu?
It is possible, but GCC/Clang setup is different. If you want, I can also provide steps for Linux or macOS.
So far, we have learned:
- Downloading and installing CodeBlocks
- Creating a project in CodeBlocks
- Running the first C program