VSCode C/C++多文件编译配置

多文件编译备忘,带注释的地方都需要注意!!!

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"
}
相关推荐
念恒123061 小时前
继承(下) (Inheritance)
c++
H Journey3 小时前
C++之 CMake、CMakeLists.txt、Makefile
开发语言·c++·makefile·cmake
研究点啥好呢7 小时前
Github热门项目推荐 | 创建你的像素风格!
c++·python·node.js·github·开源软件
_dindong7 小时前
cf1091div2 C.Grid Covering(数论)
c++·算法
沫璃染墨7 小时前
C++ string 从入门到精通:构造、迭代器、容量接口全解析
c语言·开发语言·c++
6Hzlia7 小时前
【Hot 100 刷题计划】 LeetCode 17. 电话号码的字母组合 | C++ 回溯算法经典模板
c++·算法·leetcode
计算机安禾8 小时前
【数据结构与算法】第36篇:排序大总结:稳定性、时间复杂度与适用场景
c语言·数据结构·c++·算法·链表·线性回归·visual studio
unicrom_深圳市由你创科技8 小时前
做虚拟示波器这种实时波形显示的上位机,用什么语言?
c++·python·c#
无限进步_8 小时前
【C++】电话号码的字母组合:从有限处理到通用解法
开发语言·c++·ide·windows·git·github·visual studio
计算机安禾9 小时前
【数据结构与算法】第35篇:归并排序与基数排序
c语言·数据结构·vscode·算法·排序算法·哈希算法·visual studio