GCC program compilation and gcc Compilation

Source: Internet
Author: User

GCC program compilation and gcc Compilation
1. Introduction

GCC program compilation can be divided into four stages:

  • Preprocessing (Pre-Preocessing)
  • Compile (Compiling)
  • Assembly)
  • Link (Linking)
2. Basic GCC usage

Basic usage:Gcc [options] [filename]

Common options selection and usage are described as follows:

  • -O output_filename: determines that the name of the production executable file is output_filename. If this option is not available, the compiler outputs the executable file a. out by default;
  • -C: only compiled, not connected to executable files, default outputFile Name. oFile;
  • -G: generate the symbolic information required by the debugging tool. To use the GDB debugging program, you must add this option;
  • -O: Use the compilation optimization level to optimize program compilation;
  • -O2: The program is optimized using the compilation sector with Level 2;
  • -Idirname: add the directory specified by dirname to the header file list;
  • -Ldirname: adds the directory specified by dirname to the library file list;
  • -Lname: when linking, load the function library named "libname.;
  • -Static: The program is compiled in the form of a static Link Library. If this option is not added, the dynamic link library is used by default. The files produced by the static Link Library are large;
  • -Wall: generates all warning information;
  • -W: no warning information is generated;
  • -DMACRO: equivalent# DefineDefinition macro.

Related Article

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.