Do you G-C-C What I See?

WHAT IN THE WORLD IS GCC?!?

Great question, GCC stands for GNU Compiler Collection. This is an optimizing compiler that supports various programming languages. One of them being, the C Language that we are currently learning at Holberton School through project based and collaborative peer learning.

Compilation

Compilation is a very heavy duty process of converting source code into object code. I like to say the compiler saves the day by doing the nitty gritty work while we sit back and watch. It always checks the source code for errors before generating object code. If errors are present, compiling will not be possible.

There are exactly four steps to Compilation. Let’s begin.

Preprocessing

First, we have our code that is written in a text editor like emacs or vim (pssst… EMACS) and then the file is given an extension of .c. This is the extension for all C files. Then, when passed through the preprocessor as the first step, it is expanded and passed to the compiler.

Compiling

Next, the compiler will process the source code into assembly code. We’re gettin fancy now! Files that have gone through with this step typically have extensions of .i or .ii.

Assembling

From here, the assembly code is then converted into object code and the object file’s name generated is the same as the source file. Files that have gone through assembly have the extension of .s

Linking

Last but not least! This is an essential step to making sure your file does what it is supposed to do. The linker will take all the object files and combine them into a single executable file, or library file, or other “object file”. The file will reach its final stage and have a .o extension to signify its transition to the dark side. If you do not specify what you want to be the name of your object file, it will generate the standard, which is ./a.out.

I have included a coding example from my own terminal window to illustrate my understanding of gcc and how it works:

Thank you for reading along, I appreciate and am open to any feedback that will make my posts better in the future.

Student at Holberton School

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store