C Basics · beginner · ~8 min
Compile a single .c file to a runnable binary on Linux/macOS.
C source code is text. The gcc (GNU C Compiler) program turns that text into a machine-code executable for your CPU. The typical first command is just gcc hello.c -o hello, which produces a file named hello you can run with ./hello.
Add -Wall -Wextra to enable useful warnings: most beginner bugs (uninitialized variables, comparing the wrong types, missing returns) are caught by these flags. Add -std=c11 to lock yourself to the modern dialect.
gcc -O2 -Wall -Wextra -std=c11 hello.c -o hello
./hello
-o hello — gcc writes to a.out by default.-Werror once you're comfortable.