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.