gcc command in Linux with examples (original) (raw)

Last Updated : 4 Oct, 2025

GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++.

gcc [-c|-S|-E] [-std=standard]

**Example: This will compile the _source.c file and give the output file as _a.out file which is default name of output file given by gcc compiler, which can be executed using ****./a.out**

gcc source.c

**Most Useful Options with Examples: Here _source.c is the C program code file.

gcc source.c -o opt

gcc source.c -Werror -o opt

gcc source.c -Wall -o opt

gcc -ggdb3 source.c -Wall -o opt

gcc -Wall source.c -o opt -lm

gcc -Wall -std=c11 source.c -o opt