[Setup] C Language Development Environment
To write and run C programs, you need a compiler — a tool that converts source code into an executable file. This page walks you through setting up a C development environment on both Windows and macOS.
Setting Up on Windows
There are several ways to use C on Windows.
| Method | Description |
|---|---|
| MinGW (gcc) | A lightweight compiler. You can easily compile and run code from the command line. |
| Visual Studio | Microsoft's integrated development environment. Suitable for large-scale development as well. |
Installing MinGW
MinGW is a tool that makes GCC (GNU Compiler Collection) available on Windows.
- Download the installer from mingw-w64.org.
- After installation, add the MinGW
binfolder to thePATHenvironment variable. - Run the following in Command Prompt to verify the installation.
gcc --version
If version information is displayed, the installation is complete.
Setting Up on macOS
On macOS, installing Xcode Command Line Tools makes gcc and clang immediately available. Run the following command in Terminal.
xcode-select --install
When a dialog appears, click "Install". After it completes, you can verify with the following command.
gcc --version
Compiling and Running
A C program follows this workflow: write source code → compile → run.
1. Create the source file
Use a text editor to create a file named hello.c with the following content.
hello.c
#include <stdio.h>
int main(void) {
printf("Kiryu Kazuma\n");
return 0;
}
2. Compile
Run the following in Terminal (or Command Prompt).
gcc hello.c -o hello
-o hello specifies the output filename. If omitted, the output will be named a.out (or a.exe on Windows).
3. Run
For macOS / Linux:
./hello
For Windows:
hello.exe
If Kiryu Kazuma is displayed, you're all set.
Commonly Used Compiler Options
| Option | Description |
|---|---|
| -o filename | Specifies the output filename. |
| -Wall | Enables all warnings. Useful for catching bugs early. |
| -g | Includes debug information. Use this when running with a debugger. |
| -std=c11 | Compiles using the C11 standard. Makes the target standard explicit. |
Example of compiling with warnings enabled.
gcc -Wall hello.c -o hello
As a beginner, it is recommended to always use -Wall when compiling. Warning messages will help you catch bugs.
If the Command Is Not Found
If your terminal displays gcc: command not found, the compiler may not be installed, or the PATH may not be configured correctly. Follow the steps below to check and fix the issue.
For macOS
On macOS, installing Xcode Command Line Tools makes gcc available. Run the following command.
xcode-select --install
After installation, verify it.
gcc --version
For Linux / Windows (MinGW)
Check where the gcc command is located.
which gcc
If not found, check common installation locations.
ls /usr/bin/gcc ls /usr/local/bin/gcc
Once you know the location of the command, add the PATH to your shell configuration file. First, check which shell you are using.
echo $SHELL
If /bin/zsh is shown, edit ~/.zshrc; if /bin/bash is shown, edit ~/.bashrc.
For macOS (zsh):
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
For Linux (bash):
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
For Windows (MinGW), go to "Advanced System Settings" → "Environment Variables" → "Path" and add the MinGW bin folder (e.g., C:\MinGW\bin or C:\mingw-w64\bin).
Choosing an Editor
| Tool | Description |
|---|---|
| Visual Studio Code (commonly known as VSCode) | Currently the most popular editor. Installing the C/C++ extension gives you code completion, debugging, and error highlighting. Available on Windows, macOS, and Linux. |
| Sublime Text | A lightweight, extremely fast editor. Its simple interface lets you focus on coding. Available on Windows, macOS, and Linux. |
| Hidemaru Editor | A legendary Japanese text editor first released in 1993. Lightweight, fast, and equipped with a powerful macro system. Windows only, one-time purchase. |
| CLion | A C/C++ IDE by JetBrains. Offers advanced code analysis, refactoring, and integrated debugging with CMake support. Paid. |
| Vim | A classic terminal-based editor loved by many C programmers. Highly customizable with a steep but rewarding learning curve. |
These days, Visual Studio Code seems to be the most widely used editor, but the webmaster personally loves simple and lightweight editors, so he currently uses Sublime Text. Feel free to use this as a reference.
A note about Hidemaru Editor: first released in 1993, Hidemaru is lightweight, features powerful search and replace with regular expressions, and can be customized with macros. In modern terms, macros are similar to add-ons — and Hidemaru had this capability back in the 1990s, a remarkably forward-thinking design that makes it a truly wonderful editor.
The webmaster himself used Hidemaru Editor for programming from the Windows 3.1 era through Windows 7, and owes a great deal to it over the years. Its developer, Hideo Saito, continues to update Hidemaru to this day — it runs perfectly on Windows 11 and other 64-bit versions of Windows. You can purchase Hidemaru Editor from here — it is a one-time purchase for around 4,000 yen (about $27), and having it on a Windows machine can be surprisingly handy.
(´-`).。oO(The webmaster wanted to give a personal shout-out to Mr. Saito, who he has relied on for years...)
(´-`).。oO(And yet, after 30+ years of use, the total cost has been just around $27... it's hard to find anything with better value for money...)
If you find any errors or copyright issues, please contact us.