Procedures for Linux GCC compilers

Source: Internet
Author: User

When using GCC to compile a program, the compilation process can be subdivided into four stages:

    • Pretreatment
      The preprocessing process reads into the program source code, examines the statements and macro definitions that contain the preprocessing directives, and transforms the source code accordingly. The preprocessing process removes comments and extra white space characters from the program.
    • Compile
      In the compilation phase, GCC first checks the code's normative, whether there are grammatical errors, and so on, to determine the actual work of the code to do, after the check is correct, GCC translated the code into assembly language.
    • Assembly
      The assembly phase is to convert the assembly files generated during the compilation phase to the target code.
    • Link
      Link the compiled output file to the final executable binary file


Example:

vi hello.c#include <stdio.h>int main(){        printf("hello world");        return0;}
$ ls Hello. C$ GCC-E Hello. C-O Hello. I  #预处理, output the preprocessed result as a hello.i file$ ls Hello. CHello. I$ gcc-s Hello. I    #编译, compile the preprocessed results into a compilation file$ ls Hello. CHello. IHello. S$ gcc-c Hello. S   #汇编, convert the assembly file into a target file$ ls Hello. CHello. IHello. OHello. S$ gcc Hello. O-O Hello#链接, connect the target file into a binary executable named Hello$ ls Hello hello. CHello. IHello. OHello. S

Procedures for Linux GCC compilers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.