First of all, gcc and g++ are gnu c and c++ compilers respectively, and they generally need to be divided into four steps when compiling:
1 preprocessing For cpp will generate the .i file, use the preprocessor cpp
2 to convert the preprocessed file to assembly language, generate the .s file, use the compiler egcs
3 The assembly file becomes the target file, that is, the machine code is generated. Here is the .o file generated. Use the assembler as
4 to connect the object code, generate the executable program, and use the connector ld
The main parameters are:
-x language filename It is the language used to set the file. At this time, the suffix name is invalid. Although we agree that the c language suffix is .c, the c++ language suffix name is. Cpp, but at this point we can use the suffix name at will. Commonly available parameters are: c, objective-c, c-header, c++, cpp-output, assembler, assembler-with-cpp. For example, we can use the command cpp -xc hello.xin
-x none filename This is to close the previous option, let gcc automatically determine the file type according to the suffix of the file name, such as gcc -xc hello.xin -x none Hi.c
-c is only to activate preprocessing, compiling and assembly, that is, it only makes the program into obj file, we can use gcc -c hello.c to generate .o obj file
-S only activates preprocessing and compilation, and can compile files into assembly code. For example, our gcc -S hello.c will generate assembly code for .s, which we can view using a text editor.
-E only activates preprocessing, this does not generate files, we need to redirect it to an output file, such as gcc -E hello.c > xin.txt or gcc -E hello.c |
More to see.
-o specifies the target name. The default gcc compiled file is a.out. We can use gcc -o hello hello.c.
-pipe uses pipes instead of temporary files in compilation. When using non-gnu assembly tools, you may have problems.
-undef cancels the definition of any non-standard macros
-Idir When we use #include, gcc will first look up the header files we have created in the current directory. If not found, It will go to the default header directory file. If you specify a directory with -I, it will first look in the directory we specified, and then go to the regular directory to find.
-I- is the function to cancel the previous parameter, generally used after -Idir.
-C does not delete the comment information when pre-processing, generally used with -E, it is convenient when analyzing the program
-M generates file-related information, including the target file Dependent on all source code, we can use gcc -M hello.c to test
-MM and -M are the same, but he ignores the dependencies caused by #include <file>
-MD is the same as -M, but the output is imported into the .d file.
-MMD is the same as -MM, and the output is imported into the .d file.
-library is specified to compile The library to use when.
-Ldir specifies the path to the search library at compile time, where dir is the name of our directory.
-O0, -O1, -O2, -O3 are the four levels of compiler optimization options, where -O0 means no optimization, -O1 is the default value, and -O3 has the highest optimization level. >
-g is just a compiler. When compiling, it generates debugging information.
-gstabs which generates debugging information in stabs format, but does not contain gdb debugging information.
-ggdb will generate Gdb debugging information
-static will prohibit the use of dynamic libraries, so the compiled things are generally very large
-share will try to use dynamic libraries, so the generated files are small, but need to use Dynamic library
-traditional apprentices let the compiler support traditional C language features
Today, I will share 11 cool Linux terminal commands compiled by Linux for ten years. Through
1 dr mode introduction 1.1 lvs installation 1.2 lvs mode lvs has three modes dr, nat, tun
Understand the process: ? PID, PPID? Current process status? Memory allocation? CPU and actu
How Linux extends the XFS file system. There is extra space on the disk, so I want to extend the exi
Linux server network related kernel parameters
Basic commands for learning Linux
Linux mount mountcsi, ntfs, nfs through mount
[Linux] software source installation - Tarball
9 Linux commands that must be carefully used before use
Trojan in the Linux server, manual removal method
Set the permissions of multiple groups on a file under linux (setfaclgetfacl) method - management
Ubuntu graphical desktop and command line interface Switch shortcuts
Windows7 and windows8 which is better windows7 performance is better
Who is peeping at your computer
3 ways to open Win8 screen keyboard
Win10 Build 10136 preview version of the screenshot exposure: the icon has new changes
Why is the Win7 partition more and worse
How does win10 set the system font to traditional characters?
Win10 changes, Windows membership plan terms are about to change