What is gcc?

Kais Boumaiza
3 min readSep 18, 2019

The abbreviation gcc stands for GNU Compiler Collection and was originally written to be the compiler for the GNU OS. It contains compilers for the following languages:

C, C++, Objective-C, Fortran, Java, and more

The gcc compiler was written in C and accepts options and file names as arguments so that engineers can have absolute control over the compilation process.

As you can see above there are many different options to pass into the gcc function and at the very end you can see in @file and an infile. This just basically lets a programmer specify what file should be used as input and what file they would like to specify as their output file. Many advanced software projects utilize the output of one file as the input into another file to solve a task.

How gcc main.c works ?

When writing a program in C language, it is important to remember that you must compile it in order to run it on your computer. Compiling the file will convert the contents of the file into binary code so the computer can execute it.

So how do you compile a file in the first place? One way to do it is by using the GNU Compiler Collection (gcc). gcc can compile C (gcc), C++ (g++), Objective-C, Objective-C++, Fortran (gfortran), Ada (GNAT), and Go (gccgo). The compilation process is a four-step process.

To start, you first need to type the command gcc followed by the file you wish to compile. In this instance, we’re compiling the C file main.c (we know it’s a C file because all C files have the extension .c).

The code will go through the preprocessor first, which will remove comments, include header files in source code, and replace macro names with code.

Then, the code goes through the compiler which will convert everything to assembly code. Assembly code is a combination of plain text and human readable code.

The assembly code is then sent to the assembler, which converts everything to object code. Object code is only a portion of machine code (bianry) and can contain offsets and placeholders that might not be found in completed programs.

Finally, the linker links the object code with shared or dynamic libraries. This is done because some of the symbols in your file might have entry points that exist in the shared libraries.

Once the compilation process is over, you’re left with an executable file that will be named a.out by default.

--

--