gcc Command Examples

Preprocess and compile C and C++ source files, then assemble and link them together. Part of GCC (GNU Compiler Collection). More information: https://gcc.gnu.org.

gcc {{path/to/source1.c path/to/source2.c ...}} {{[-o|--output]}} {{path/to/output_executable}}

gcc {{path/to/source.c}} -Wall {{[-o|--output]}} {{output_executable}}

gcc {{path/to/source.c}} -Wall {{[-g|--debug]}} -Og {{[-o|--output]}} {{path/to/output_executable}}

gcc {{path/to/source.c}} {{[-o|--output]}} {{path/to/output_executable}} -I{{path/to/header}} -L{{path/to/library}} -l{{library_name}}

gcc {{[-S|--assemble]}} {{path/to/source.c}}

gcc {{[-c|--compile]}} {{path/to/source.c}}

gcc {{path/to/source.c}} -O{{1|2|3|fast}} {{[-o|--output]}} {{path/to/output_executable}}

gcc --version