0-15 GCC Program compilation

Source: Internet
Author: User

Usage: gcc [...] filenames

Example: GCC hello.c

Output: a.out

Procedure: hello.c pre-mutation hello.i after compilation Hello.s post hello.o link after hello


Pre-compilation:

GCC-E Hello.c-o hello.i

Compile:

Gcc-s Hello.i-o Hello.s

Assembly:

Gcc-c Hello.s-o hello.o

Link:

GCC Hello.o-o Hello


File format:

*.C C Language Source code

*.h header File

*.A Library file

*.O target file

*. C *.cc *.cpp C + + files

*.S *. S assembly File


GCC compilation options:

-o Specifies the output executable file

-O to optimize the compilation of the program

-o2 better compiling for the program, consuming more time

-C only compile not connected, output *.O target file

-G produces the required symbols for GDB for debugging


Linux system header files are generally stored in the/usr/include, if the header file is stored in the current directory, the reference format is:

#include "XXX.h"

Or, use the-I option to specify where the header file is stored, such as:

Gcc-i/root Hello.c-o Hello


Pre-compiled use:

#define PRINT

#ifdef PRINT

...

#endif

This article is from the "Home Life" blog, please be sure to keep this source http://elvin1122.blog.51cto.com/9889796/1838340

0-15 GCC Program compilation

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.