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.