vscode运行多个.cpp、.h的方法(只有一个main)
首先最重要的是找到g++.exe,gdb.exe, gcc.exe,在MinGW中就有,。(每个人有每个人的存储位置,下面是我的)

我们找到之后就可以得到他们的路径了,也就是上面那一行,这一行在后面将会用到,若是你没有MinGW,建议去下载一个。
接下来,我们开始配置两大文件,他们就是.vscode文件夹下的tasks.json、launch.json,这两个文件是调试的基础,同时也是我们编译多个cpp的基础。
下面是我目前(2020/7/26)使用的两大文件,都是我特意选出来的,仅供参考!
tasks.json
{
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file", //与launch.json的preLaunchTask一致
"command": "C:\\MinGW\\MinGW\\mingw\\mingw64\\bin\\g++.exe", //g++.exe的路径
"args": [
"-g",
"${workspaceFolder}\\**.cpp", //${workspaceFolder}表示.vscode所在的那个文件夹的路径
"-o",
"${workspaceFolder}\\${fileBasenameNoExtension}.exe" , //与launch的program对应
"-std=c++17"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": {
"owner": "cpp",
"fileLocation":[
"relative", "${workspaceFolder}"
],
"pattern":{
"regexp": "%(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
launch.json
{
1万+


&spm=1001.2101.3001.11974&articleId=107596220&d=1&t=3&u=5cb5367b9ad340beaf2ed1791b63cbcd)

被折叠的 条评论
为什么被折叠?



