What happens when you type gcc main.c?

GNU Compiler Collection

If you are here and don’t have any idea about what we are talking about, so, Let’s define some terms before we start

What is a Compiler? It is a program that takes an input called high-level programming language and translate into an output called lower level language with the purpose to create a executable program. This applies to computer programs.

Into the compilation process occurs 4 sub-process called: Preprocessor, compiler, assembler and linker.

Preprocessor: It is ensured that all files are necessary taken to the compiler.

Compiler: Translates a high level language into machine code .

Assembler: Translate assembly intermediate files into a native assembly

Linker: Create an executable file.

now! what we came here? ahhh! what happens when you type gcc main.c?

but, What’s gcc? is a GNU compiler Collection. A compiler system produced by GNU project. And What’s main.c? In this case is the program(into a file for language C, for that reason the extension is .c) that we are going to convert into an executable.

Let’s see an example: we have the file main.c in our pc. In that file we write a program in C language that print the abc in lowercase and uppercase.

file main.c after type command ls -l in our terminal

and now we are write gcc main.c in the terminal

after that, the command gcc create a new fille called a.out. The file a.out is the executable, is the result of the compiler.

now, we execute the file a.out with the line ./a.out

finally the program was executed and we have the result in the terminal, you can see the abc in lowercase and uppercase.

Leave a comment

Design a site like this with WordPress.com
Get started