1.GCC compiler
The GCC compiler was initially developed for the C compiler (GNU C Compiler), but over time the GCC compiler was able to support multiple languages.
1.1 Use of the GCC compiler
If we already have a. c file name is called HELLO.C, you can use the following statement to compile the file:
$ gcc hello.c
After the statement executes successfully, the executable file name is generated in the current directory called a.out (the default), and we can use the following statement to run the executable:
$./a . Out
Of course we don't want to use the default name, which is not intuitive enough for us to specify its executable file name when we compile with GCC:
$ gcc-o Hello hello.
The default a.out file name is replaced with "Hello";
1.2 Compiling relevant options
In many cases the programmer does not want an executable file so simple, some situations require the target code, some occasions need to assemble the code and so on, the following list of compiler-related options:
-C only activates preprocessing, compilation, and assembly, and generates a target code file with an. o extension;
-S only activates preprocessing and compilation, generating assembly code files with the extension. S;
-e only activates preprocessing and outputs the result to standard output
-G generates related information (such as GDB) for the debugger
1.3 Optimization Options
GCC offers 3 levels of optimization for programmers to choose from, from low to high in turn-o1,-o2 and-o3. Theoretically, the-O3 can generate the most efficient code, but the higher the degree of optimization the higher the risk, the more often the-O2 is used. In fact, the three-level optimization is packaged for a variety of specific optimizations, specific to the GCC official manual, and using the-march option to compile binary code for a specific CPU, but not for special occasions do not use the-march option.
$ gcc-o2-o Hello hello.c
2.g++ compiler
Although GCC can compile C + + source files, it cannot automatically connect to C + + libraries, so it is common to use g++ to compile and link C + + source files.
Use of the g++ compiler
The use of the g++ compiler is basically consistent with GCC.
The GCC and g++ compilers for Linux