0. In this article, VsCode running on Windows 11 remotely connects to the Linux system through SSH
reference
Reference: Configure C/C++ environment in Linux system VS Code
Reference: Configure C/C++ environment in vscode (GCC on Linux, a day to read official documents~)
1. Install g++, gcc, gdb
Check whether g++, gcc, gdb are installed
// 打印版本信息,注意v是小写的
gcc -v
g++ -v
gdb -v
If the output
is output, it means
installation
sudo apt-get install build-essential
After installation, both g++ and gcc can be successfully installed, but the following error occurs in gdb.
At the same time, after entering the following command
apt install gdb
If the following error occurs
, you need to do the following
apt-get update
apt-get upgrade
apt-get install packagename
2. VsCode settings
install plugin
- C/C+//required
- Code Runner//required
- C/C++ Snippets // Suggestions, provide some commonly used C/C++ snippets
- EPITECH C/C++ Headers // Suggestions, add headers (including author, creation and modification date, etc.) for C/C++ files, and add anti-duplication macros for .h header files
- File Templates // Suggestions, file templates, you can add file templates yourself
- GBKtoUTF8 // Suggestion, convert GBK encoded file to UTF-8
- Include Autocomplete // suggestion, header file auto-completion
- One Dark Pro // Suggestion, you can create a good-looking VS Code theme
Search for code runner run in terminal in the settings, tick
run
Select the compiler:
ctrl+shift+p to open the command panel, search for Configure Default Build Task.
I don't know the difference between these compilers. Both the first and second try can run the .cpp file
Note that **.cpp needs to be active when searching
Under the .vscode folder, the tasks.json file saves the settings for running the file.
debugging
Ctrl+shift+p opens the command panel and searches for Add Configuration.
Select the debugger
Under the .vscode folder, the launch.json file saves the settings of the debug file.
Finish
If you want to remove
[1] + Done “/usr/bin/gdb” --interpreter=…,
you can add an item to the configurations field in the launch.json file:
"miDebuggerArgs": "-q -ex quit; wait() { fg >/dev/null; }; /bin/gdb -q --interpreter=mi",