gcc compiler option description for Linux system programming

Source: Internet
Author: User
Keywords LINUX GCC compiler
Tags aliyun apple compile compiled compiler compilers developed example

Gc++ (GNU Compiler Collection,gnu Compiler Set) is a set of programming language compilers developed by GNU. It is a set of &http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;" The GNU compiler set with free software issued under the GPL and LGPL licenses is a key part of the GNU program, as well as a standard compiler for free Unix-like and Mac OS X operating systems.

GCC was formerly known as the GNU C language compiler because it could only handle the C language. GCC quickly expands to be able to handle C + +. It also becomes available to deal with Fortran, Pascal, C, Java, and Ada and other languages.

The following is a description of the GCC common compilation options:

-C Option:

Compiling the source program into the target code without doing the link work, so the compiled instruction with this option does not generate a final

Executes the program, instead generating an object file with the. o suffix that is the same as the source program file name.

Example: # gcc-c TEST.C

The above command generates only TEST.O files.

-S option:

Use this option to generate only one assembly language file with a suffix named. S.

-E option:

Preprocessing only.

-V Option:

Displays the GCC version.

Example: # gcc-v

-X option:

Specifies the compiled language.

Example: # gcc-x C + + test.c

Indicates that a C + + compiler is used to compile the TEST.C program.

-I option:

Specifies the library and header file path.

In general, most functions under Linux place the header file in the System/usr/include directory, and the library file

is placed in the/usr/lib directory. But in some cases it's not, in these cases, using GCC compile-time

You must specify the path of the desired header file and library file.

Example: # gcc-i/home/include-o Test test.c

Specifies that the header file path is/home/include.

-L Option:

Specifies the path of the dependent library.

-static option:

Forces the program to connect to the static library.

-O Option:

Specifies the file name of the generated executable program.

Example: # Gcc-o Test test.c

Specifies that the test.c file be compiled and the executable file test is generated.

-W Option:

Suppresses the output of warning messages.

-werror option:

Converts all warnings to errors.

-wall option:

Displays all warning messages.

-O Option:

Compile-time Use option-O can tell GCC to reduce the length and execution time of the code at the same time, the effect is equivalent to-o1.

-O2 option:

Option-o2 tells GCC that in addition to completing all the-o1 level optimizations, there are some additional adjustments to be made,

such as processor instruction scheduling.

-G option:

Generate debugging information.

-PG option:

Once the compilation is complete, additional information is required for profiling.

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.