多文件编译备忘,带注释的地方都需要注意!!!
launch.json文件
cpp
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/out.exe",//1、 文件目录 执行程序.exe路径
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}", //2、文件目录
"environment": [],
"externalConsole": true, //3、 显示控制台窗口
"MIMode": "gdb",
"miDebuggerPath": "D:\\App\\Microsoft VS Code\\mingw64\\bin\\gdb.exe", //4、 gdb.exe路径
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件" //链接task.json,这个名称必须要与task.json中的label名称一致否则会编译出错
}
]
}
task.json文件
cpp
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件", //1、 与launch.json中preLaunchTask的名称一致
"command": "D:\\App\\Microsoft VS Code\\mingw64\\bin\\g++.exe", //2、 c++编译器g++.exe的路径
"args": [
"-fdiagnostics-color=always",
"-g",
"${fileDirname}/*.cpp", //"${file}", //多文件编译
"-o",
"${fileDirname}/out.exe" //"${fileDirname}\\${fileBasenameNoExtension}.exe" //多文件编译成功生成的可执行文件.exe
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}