vscode 1.42.1
OS: windows 7 x64
1. vscode, cpp extension
本文直接跳過 vscode 安裝, Cpp tools 安裝
2. MinGw 安裝及配置
下載MinGW - Minimalist GNU for Windows
安裝過程
安裝所需依賴環(huán)境
3. 配置環(huán)境變量
4. 調(diào)試
配置 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true, // 這里要改為true
"MIMode": "gdb",
"miDebuggerPath": "D:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++"
}
]
}
配置task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "g++",
"type": "shell",
"command": "D:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new",
"showReuseMessage": true, //這里shared表示共享,改成new之后每個(gè)進(jìn)程創(chuàng)建新的端口
"clear": false
}
}
]
}
最后結(jié)果
參考
- 整理:Visual Studio Code (vscode) 配置C、C++環(huán)境/編寫運(yùn)行C、C++(主要Windows、簡要Linux)
- vscode 基本知識(shí)以及如何配置 C++ 環(huán)境
- 關(guān)于VScode報(bào)錯(cuò)“終端將被任務(wù)重用,按任意鍵關(guān)閉”的解決方案
- VSCode 代碼調(diào)試器
- windows 10上使用vscode編譯運(yùn)行和調(diào)試C/C++
公號(hào) [ 同叔練級(jí)之路 ]
Certainty of death. Small chance of success.
|