Using g++ and gdb
G++ is the C++ compiler under Unix/Linux, and gdb is a powerful debugging tool under Unix/Linux. Most of the time, the C/C++ code we write does not run on Windows but on a Linux system. Here I record some usage of g++ and gdb in case they are needed. Using g++ When g++ performs compilation work, it needs 4 steps in total: Preprocessing, generating a .i file, mainly expanding header files and macro definitions: g++ -E test.cpp -o test.i Compilation, converting the preprocessed file into assembly language and generating a .s file: g++ -S test.i -o test.s Assembly, turning the assembly into object code (machine code) and generating a .o file, mainly converting the .s file into a binary file: g++ -c test.s -o test.o Linking, linking the object code to generate an executable program: g++ test.o -o test The steps above can also be done with a single command: ...