The process of the GCC command using it with a file.

Victor Rivera
3 min readFeb 5, 2020
This Binary which is a language used by the computer.

In C programming, the user has to use a certain command that will both form their C program and make it executable. That would be the GCC command which stands for “GNU Compiler Collection”. It is a amalgamated distribution to many programming languages. Basically GCC is a tool used with several different programs. In this case, it used by C and C++ to create executable or useable C programs. It used like this:

The rectangle next to the command is the cursor on the terminal.

What does GCC do? GCC Preprocesses, Compiles, Assembles, and Links the C Program File. For the topic, I will be using a file named ‘main.c’ to showcase examples. Now to break down each of the processes.

Preprocessing: This is the step where the program file has comments (written like this: /** comment */) removed from the program, copies the header file which looks like this (#include <header.file>) and define longer constructs. Longer constructs are know as macros.

Compilation: In this step, gcc basically prepares and pieces together your code for the final two processes.

Assembly: Computers use Binary, or simply put numbers as it is the language it reads and executes off it, even when we write English or any other language to it. So in regards this step, the Compiler translates the C Program File to Binary for the computer to understand and build. When this is finished, it moves on to the final step.

Linking: Linking pieces everything together and readies the program to be executed by creating a file named:

Note: This is my terminal coloring it green! You can customize your terminal to display different items in different colors!

The file ‘a.out’ is the executable program based off of the C Program File:

Which was typed like this on the command line:

Now there are options that can control the GCC process.

  • -c will Compile and/or Assemble the program file but will not link it.
  • -S will stop after the Compilation stage and will not assemble the program. By typing this on the command line:

You will get this file in your folder/directory:

  • E is an option for GCC that will stop after the preprocessing stage used like so:

And would output a long, messy display of text. I don’t recommend it!

Errors will happen when typing the syntax incorrectly, so it’s best to be careful.

There you have it, the process of GCC, what it is, and it’s additional options. I hope this helped building an understanding of what the command can do.

--

--

Victor Rivera
0 Followers

Hey there, I'm Victor. I'm a student at Holberton School for Software Engineering!