How to Install GCC on Windows with w64devkit
Source: Dev.to
Installing w64devkit
- Go to the w64devkit GitHub releases page and download the latest .zip archive.
- Extract the contents to a folder of your choice (e.g.,
C:\w64devkit).
No further installation steps are required.
Launching the w64devkit terminal
- Locate
w64devkit.exein the folder you extracted. - Double‑click it to open a pre‑configured MinGW64 shell.
Navigating to your project
# Example: your project is in C:\Users\YourUser\Documents\MyCProject
cd /c/Users/YourUser/Documents/MyCProject
Use forward slashes (
/) for paths in this Unix‑style shell.
Compiling C programs with GCC
Simple compilation
gcc main.c -o main_executable
main.c– source file-o main_executable– name of the resulting executable (main_executable.exe)
Common compilation flags
-WallEnable a broad set of warnings.-WextraEnable additional warnings beyond-Wall.-WerrorTreat all warnings as errors, forcing you to fix them.-std=c99Target the C99 language standard.-oSpecify the output executable name.
Example for a multi‑file project
gcc -Wall -Wextra -Werror -std=c99 main.c array_helpers.c -o peak_finder
This compiles main.c and array_helpers.c, applies the selected warnings (as errors), adheres to the C99 standard, and produces peak_finder.exe.
Running the executable
./peak_finder
The ./ prefix tells the shell to look for the executable in the current directory.
Passing command‑line arguments
./peak_finder test_array.txt
test_array.txt will be received by your program as an argument.
You can find more posts on my personal blog: