Michael Galindez
3 min readFeb 5, 2020

What happens when you type gcc main.c ?

First, we need to know what is GCC?. 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++. The most important option required while compiling a source code file is the name of the source program, rest every argument is optional like a warning, debugging, linking libraries, object file etc. The different options of gcc command allow the user to stop the compilation process at different stages.

The original GNU C Compiler (GCC) is developed by Richard Stallman, the founder of the GNU Project. Richard Stallman founded the GNU project in 1984 to create a complete Unix-like operating system as free software, to promote freedom and cooperation among computer users and programmers.

This is the syntaxis of GCC:

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 Usefull Options:

-o opt: This will compile the source.c file but instead of giving default name hence executed using ./opt, it will give output file as opt. -o is for output file option.

gcc source.c -o opt

-Werror: This will compile the source and show the warning if any error is there in the program, -W is for giving warnings.

gcc source.c -Werror -o opt

-Wall: This will check not only for errors but also for all kinds warning like unused variables errors, it is good practice to use this flag while compiling the code.

gcc source.c -Wall -o opt
  • c : This command compile the program and give the object file as output, which is used to make libraries.
  • v : This option is used for the verbose purpose.

GCC Versions

The various GCC versions are:

  • GCC version 1 (1987): Initial version that support C.
  • GCC version 2 (1992): supports C++.
  • GCC version 3 (2001): incorporating ECGS (Experimental GNU Compiler System), with improve optimization.
  • GCC version 4 (2005):
  • GCC version 5 (2015):
  • GCC Version 6 (2016):
  • GCC Version 7 (2017):

You can get the help manual via the --help option. For example,

$ gcc --help

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Michael Galindez
Michael Galindez

Written by Michael Galindez

0 Followers

Computer Science Student

No responses yet

Write a response