Skip to content

gcc-g++ parameters1. Compilation steps

  1. 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
  2. -c
    Only activate preprocessing, compilation, and assembly, do not connect, and generate obj (*.o) files
  3. -o
    Specify target file name
  4. -S
    Preprocessing + compilation, no assembly connection
  5. -E
    Only preprocessing
  6. -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.
  7. -g
    Generate debugging information at compile time
  8. -ggdb
    Generate debugging information that gdb can use when possible
  9. -w
    Does not generate any warning message
  10. -Wall
    Generate all warning messages
  11. -Wl,-options1,-options2
    Connection options
  12. -LLIBRARY
    Search the specified function library when connecting
  13. -IDIRECTORY (this is a capital i)
    Specify additional header file search paths
  14. -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.
  15. -static
    Static linking shared library files
  16. -shared
    Connect multiple target files to generate a shared library file ending in .a