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: ...

March 2, 2018 · 5 min · Simplestory

Compiling C/C++ under Vscode

Visual Studio Code is a lightweight editor released by Microsoft; by installing various plugins it can be turned into a powerful multi-language, cross-platform compiler. Recently, because of practical needs, I had to debug some C/C++ code, so I started tinkering with Vscode. Below is a record of the problems that troubled me during the process. The system used in this post is ubuntu16.04LTS I will not go into the details of installing Vscode on linux, as Baidu has plenty of resources on that. ...

October 1, 2017 · 2 min · Simplestory