Linux programming basics 1 GCC program Compilation

Source: Internet
Author: User
1 Introduction

GCC (GNU Compiler Collection, GNU Compiler set) is a programming language compiler developed by GNU. It is a set of Free Software issued with GPL and lgpl licenses in the GNU Compiler package.
The key part of the GNU program is the standard compiler for free UNIX-like and Mac OS X operating systems on Apple computers.

2. compilation process

2.1 The compilation involves four steps:
1. Pre-processing)
2. Compile (Compiling)
3. Assembly)

4. Link (linking)


2.2 The file suffixes and types involved in compilation are as follows:
. C: C language source code file
. A: library file consisting of the target file
. C,. cc or. cxx: C ++ source code file
. H: header file
. I: C source code files that have been preprocessed
. II: C ++ source code files that have been preprocessed
. O: the target file after compilation
. S: assembly language source code file

. S: Pre-compiled assembly language source code file


2.3 The entire compilation process is shown in figure 2.1:



Fig 2.1

Iii. GCC commands

2.1 GCC command format:

GCC [Options] [filenames]


2.2 options:
-O [output_filename]: target file name
-C: Only. O is compiled.
-G: compile with debugging information. It is used for GDB debugging.
-O: optimized
-O2: more optimized
-I [include_folder_path]: add the target directory to the GCC standard header file directory.
Note: # include <>: Find files from the GCC standard header file directory, such as/usr/include/
Note: # include "":
Current Directory
-L [library_folder_path]: directory of the file to be added to the database
-L [lib_name]: reference the library file. The path must be added in the default library path or-l
-Static: static Library Link file
-Wall: generates all warning information.
-W: no warning information is generated.
-D: equivalent to define

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.