Linux Ubuntu 003 -- gcc/g ++ Compiler

Source: Internet
Author: User

LinuxThe number of commonly used compilers in the environment should beGcc/g ++Unless it is not usedC/C ++AsProgramming Language.GccAndG ++YesLinuxThe fact standard of the platform compiler.

GccProgramCompilation process:

UseGcc/g ++During program compilation, the compilation process should be divided4Stages:

1. Preprocessing(Pre-processing);

2. Compile(Compiling);

3. Assembly(Grouping);

4. Links(Linking).

GccYou can compile the file. Generally, only one instruction is required.

Assume that we have a name namedHello. cpp"Hello, world!"File to compile and output the desired results. The following command is required:

GccHello.CPP-O hello

In some cases, it is often necessary to handle unexpected situations and compile some intermediate files in the program process,GccYou can also use the step-by-step method to compile files. The parameter"-E,-S,-OYou can obtain*. I,*. S,*. OFiles. These are all intermediate files.

File*. IIs the file generated by preprocessing;*. SIs the compiled assembly language file.*. OBinary machine generated by AssemblyCode.

The following commands can be used for the overall process:

 
Gcc-E hello.CPP-O hello. IGcc-S hello. I-O hello. oGccHello. O-O hello

Generate an executable fileHello

You can also omit some intermediate steps to simplify the process as follows:

Gcc-C hello.CPP-O hello. oGccHello. O-O hello

From the preceding instructions, we can see that,GccThe basic usage is:

 
Gcc<Options> [filename]

For more information about the parameters, see the help documentation:

●-C only compiles and does not link to a self-built file, that is, a *. o file is generated.

●-O output_filename determines the output file name. If it is not determined, a default file name a. Out is generated.

●-G generates debugging information.

●-O optimizes program compilation and links.

●-Wall outputs all warning information.

●-W: Disable all warning information.

●-Idirname: add the directory named dirname to the program header file directory list.

 

PS:

When I first installed Ubuntu, I also downloaded a code: blocks to write c ++.Code.VimAndGcc/g ++Finally, you canCode: blocks this little thing is completely discarded and uninstalled.

I installed Ubuntu March 20 LTS In 12.04 and now I can use Linux to write programs. I am also getting used to using the terminal cli. I am also familiar with basic commands.

Learning Linux has benefited a lot from the video www.linuxcast.net. The Basics of getting started with Linux have been read, followed by reading the book and taking the content properly.

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.