Skip to main content

The gcc command preprocesses and compiles C and C++ source files, then assembles and links them together.

# To compile multiple source files into executable:
gcc <source_file_1.c> <source_file_2.c> -o <output_executable_file>

# To allow warnings, debug symbols in output:
gcc <source_file.c> -Wall -Og -o <output_executable_file>

# To include libraries from a different path:
gcc <source_file.c> -o <output_executable_file> -I<header_path> -L<library_path> -l<library_name>

# To compile source code into Assembler instructions:
gcc -S <source_file.c>