4 steps to achieve gcc compiler

Step 4 gcc compiler

  • Pretreatment (hollo.c-> hello.i)

     gcc -E
    • Expand macros, header files

    • Replace compile condition

    • Delete comments, blank lines, blank

  • Compile (hello.i-> hello.s)

    gcc  -S
    • Check the syntax specification
    • The most time-consuming, most system resources
  • Compilation (hello.s-> hello.o)

    gcc -c
    • The assembly instructions translated into machine instructions
  • Link (hello.o-> a.out)

    • The combined data segment
    • Address backfill

Some methods of GCC

parameter effect Case
-I Uppercase I, you can specify the header file path gcc -I ./inc hello.c -o hello
-O Lowercase o, can be directly translated into the document file may be performed .exe / .out gcc hello.c -o hello.out
-c Lowercase C, only pre-compiler, assembler, compiled into a binary file .o gcc hello.c -c
-g Lowercase g, add debug file when compiling gcc hello.c -o hello -g
-On Capital O, need to be optimized to keep the numerical optimization, such as O1, O2, O3, the default level is 2, the range of 0 to 3, n ranges from greater better optimization gcc hello.c -o hello -O3
-Wall Wall, may prompt more warnings gcc hello.c -o hello -Wall
-D Macros can be specified at compile time, dynamic registration macro gcc hello.c -D hello

Guess you like

Origin www.cnblogs.com/fandx/p/12518355.html