Loading lessons...
Compiling and Running
Compiling and Running
The compiler turns .c source into a runnable program.
Typical commands
Bash
gcc hello.c -o hello
./helloFlags
-onames the output file.-Wallshows all warnings.-gadds debug information.-O2optimizes for speed.
Warnings are your friends
Bash
gcc -Wall -o hello hello.cFix every warning; they become bugs later.
Link extra libraries
Bash
gcc prog.c -lm # math library
gcc prog.c -lpthread # threadingTL;DR
gcc source -o binary.-Wallreveals issues.-genables debugging.- Link libraries with
-l.