Common gcc/g ++ commands and gcc Command Options

Source: Internet
Author: User

Common gcc/g ++ commands and gcc Command Options

Common options for gcc/g ++ commands (option description)

-O FILE specifies the output FILE name. This option is not required during compilation of the target code. If FILE is not specified, the default FILE name is a. out.

-C: only compile and generate the target file without Link

-Msung optimizes code for 486.

-O0 is not optimized.

-O or-O1 optimized code generation.

-O2 is further optimized.

-O3 is further optimized than-O2, including the inline function.

-W: Disable all warnings. Do not use this option.

-Wall allows you to issue all the useful warnings that gcc can provide, or you can use-W (warning) to mark the specified warning.

-Werror converts all warnings to errors to abort the compilation process when a warning occurs.

-MM outputs a make-compatible list

-V shows the commands used in each step of the compilation process.

-E only runs the C pre-compiler.

-Shared object generation. It is usually used to create a shared library.

-Static link: the static link is executed.

-LFOO: link the function library named libFOO.

-G contains standard debugging information in the executable program

-Ggdb contains only GNU debugger in the executable program so that up to two other items are information.

-O optimized compiled code

-ON: Specifies the code optimization level as N, o <= N <= 3

-Ansi supports the standard syntax of ANSI/iso c and removes parts of the GNU syntax extension that conflict with this standard (but this option does not guarantee the generation of ANSI compatible code) this option will disable certain characteristics of gnu c, such as asm or typeof keywords.

-Pedantic allows all warnings listed in ANSI/iso c standards

-Errors allows the issuance of all errors listed in ANSI/iso c standards

-Traditional supports Kernighan & Ritchie C syntax (for example, defining a function using the old syntax). It does not matter if you do not know the meaning of this option.
-IDIRECTORY: specify an additional header file to search for the path DIRECTORY.

-LDIRECTORY: specify an additional function library to search for the path DIRECTORY.

-DFOO = BAR defines the pre-processing macro FOO in the command line, and its value is BAR

-IDIRNAME: Add DIRNAME to the search directory list of the header file.

-LDIRNAME: adds DIRNAME to the search directory list of the library file. By default, gcc only links to the shared library.

-DMACRO defines the MACRO with the string "1.

-DMACRO = DEFN: Define the MACRO with the string "DEFN.

-UMACRO undefines MACRO macros.

Use g ++ to compile the CPP file. If you use gcc to compile the C ++ source file, use the following option:-lstdc ++. Otherwise, an error occurs when the C ++ operation is used.

 

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.