What happens when you type gcc main.c

What happens when you type gcc main.c

GNU

It is a operating system that is compatible with Unix, it was developed by the GNU project, which started in 1983 by Richard Stallman; he wanted to produce non-proprietary software.

C

C is a programming language very known around the world, it is one of the firs 10 programming languages. Programming languages are divided into two categories:

Interpreted languages:

Compiled languages: C is a compiled language, which means that it has the next process; preprocessed, compiled, assembled, and finally linked. With these 4 process the program runs (it happens when gcc main.c is ran from your terminal)

GCC

GNU means Compiler Collection and was originally written to be the compiler for the GNU OS. It compilers the following languages: C, C++, Objective-C, Fortran, Java, and more.

gcc main.c

It runs four steps and always in the same order

No hay texto alternativo para esta imagen

Preprocessing

It is a separate program that is called by the compiler before the actual translation begins. Such a preprocessor can delete comments, include other files and replace macro substitutions.

You can preprocess a “c file” by running the following command

$ gcc -E main.c 

Compilation

A compiler is a type of translator that transforms a program from one programming language (called source code) to another. The above command creates a file called main.s which contains the assembly code for the main.c file

To generate assembly code from a C source file, see the following

$ gcc -S main.c

Assembly

It is the phase of the software compilation, which consists of transforming a file written in assembly language into an object file or binary file. The output of the assembler is put in a file called main.o . This output becomes the final input into what is called the linker in the compilation process

Linking

The linker is a process that accepts as input object files and libraries to produce the final executable program. The linker accepts the main.o as input and it also accepts any pre-compiled libraries that were imported with the #include preprocessor directiv

No hay texto alternativo para esta imagen


要查看或添加评论,请登录

Marisol R.的更多文章

  • What happens when a web page is opened?

    What happens when a web page is opened?

    Visiting web pages daily became normal, we use web pages to consult information, enjoy entertainment, search for…

  • IoT explanation

    IoT explanation

    Since the arrival of the Internet in our lives, it has evolved in a fast and overwhelming way, from those rudimentary…

    1 条评论
  • Explaining Machine Learning in a simple way

    Explaining Machine Learning in a simple way

    The first step to understand the operation and concepts of Machine Learning is to know that there are branches very…

  • Everything is object

    Everything is object

    Introduction To start with the subject of objects, the first thing to know is that they are part of object-oriented…

  • Differences between static and dynamic libraries

    Differences between static and dynamic libraries

    Why using libraries Before explaining how libraries work, you must know that they are used to facilitate programming…

  • What happens when you type ls -l in the shell

    What happens when you type ls -l in the shell

    The purpose of this article is that you learn in an easy way what happens when you type ls -l in the shell. First, you…

  • C static libraries

    C static libraries

    Why use libraries? Before explaining how do static libraries work, you must know that they are used to facilitate…

社区洞察

其他会员也浏览了