Image for post
Image for post

Although it may seem tiny, running gcc main.c has a broad impact. Before we dive into the details, it’s important to clarify a few things. The command gcc runs something called the GNU Compiler Collection. This is a compiler from the GNU project, a mass collaborative initiative aimed at developing free software. The project was founded by Richard Stallman in 1978 at MIT. Along with the gcc compiler, the text editor Emacs also comes out from this project.

The GNU Compiler Collection follows the C compilation process, first starting with a source code file ending in the file type .c. For this rundown, think of a standard main.c file with a few simple lines of code.

When compiling with gcc, flags may be passed to check for different fields. When in doubt, using -Wall will output all error messages with some details about where to find the error within the line and character count. If everything goes well, the code is sent to the preprocessor. There the comments will be removed and the code gets a little farther from human readability.

Next is the compiler, where the code is turned into assembly code. This is definitely farther from human readability, but not quite the machine readability that binary offers, so off the code goes to the assembler. There it will become object code and swiftly sent to the linker to bring it all home. The linker will select libraries and merge it with that object code, then finally outputting an executable file. This is now a machine readable C file!

Written by

Cosmetologist to Coder — Holberton School New Haven

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