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