gcc-g++ parameters1. Compilation steps¶
- Preprocess and generate .i file 2. Convert the preprocessed files into assembly language and generate .s files 3. From assembly to object code, generate .o file 4. Connect the target code and generate an executable program2. Common parameters
- -c
Only activate preprocessing, compilation, and assembly, do not connect, and generate obj (*.o) files - -o
Specify target file name - -S
Preprocessing + compilation, no assembly connection - -E
Only preprocessing - -O0/-O1/-O2/-O3
There are 4 levels of compiler optimization, -O0 has no optimization, -O1 is the default value, and -O3 has the highest optimization level. - -g
Generate debugging information at compile time - -ggdb
Generate debugging information that gdb can use when possible - -w
Does not generate any warning message - -Wall
Generate all warning messages - -Wl,-options1,-options2
Connection options - -LLIBRARY
Search the specified function library when connecting - -IDIRECTORY (this is a capital i)
Specify additional header file search paths - -nostartfiles -nostdlib
It is necessary to run bare metal without Linux. -nostartfiles does not connect to the system standard startup files. -nostdlib includes -nostartfiles and standard libraries. - -static
Static linking shared library files - -shared
Connect multiple target files to generate a shared library file ending in .a