Gcc compiler

Samir Millan
2 min readSep 19, 2019

--

What is it Gcc?…
GCC is an integrated compiler of the GNU project for C, C ++, Objective C and Fortran; It is able to receive a source program in any of these languages ​​and generate a binary executable program in the language of the machine where it is to run.
The acronym GCC stands for “GNU Compiler Collection”. Originally it meant “GNU C Compiler”; GCC is still used to designate a compilation in C. G ++ refers to a compilation in C ++.

Suffixes in file names…
Options:
- C
Performs preprocessing and compilation, I get the file in object code; Does not link.
- E
Performs only preprocessing, sending the result to standard output.
-o file
Indicates the name of the output file, whatever the steps completed.
-Iruta
Specifies the path to the directory where the files marked to be included in the source program are located. It does not take space between the I and the route, like this: -I / usr / include
-L
Specifies the path to the directory where the library files are located with the code object of the functions referenced in the source program. It does not take space between the L and the route, like this: -L / usr / lib
-Wall
It shows all the compiler’s error and warning messages, even some questionable but ultimately easy to avoid by writing the code carefully.
-g
it includes in the executable generated the necessary information to be able to track the errors using a debugger, such as GDB (GNU Debugger).
-v
It shows the commands executed at each compilation stage and the compiler version. It is a very detailed report.
Stages of compilation.

CCG compilation process…

1.Pre-processing: via the GNU C Preprocessor (cpp.exe), which includes the headers (#include) and expands the macros (#define).
> cpp hello.c > hello.i
The resultant intermediate file “hello.i" contains the expanded source code.

2.Compilation: The compiler compiles the pre-processed source code into ssembly code for a specific processo.
> gcc -S hello.i
The -S option specifies to produce assembly code, instead of object code. The resultant assembly file is "hello.s".

3.Assembly: The assembler (as.exe) converts the assembly code into machine code in the object file "hello.o".
> as -o hello.o hello.s

4.Linker: Finally, the linker (ld.exe) links the object code with the library code to produce an executable file "hello.exe".
> ld -o hello.exe hello.o …libraries…

--

--

Samir Millan
Samir Millan

No responses yet