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"
}
相关推荐
acanab1 天前
VScode python插件
ide·vscode·python
666HZ6661 天前
数据结构2.0 线性表
c语言·数据结构·算法
SmartRadio1 天前
ESP32添加修改蓝牙名称和获取蓝牙连接状态的AT命令-完整UART BLE服务功能后的完整`main.c`代码
c语言·开发语言·c++·esp32·ble
charlie1145141911 天前
嵌入式的现代C++教程——constexpr与设计技巧
开发语言·c++·笔记·单片机·学习·算法·嵌入式
济6171 天前
嵌入式C语言(第二期)
c语言
Dillon Dong1 天前
STM32嵌入式:使用 MT29F8G08ABACAWP NAND 的FLASH全面指南
c语言·stm32
CSDN_RTKLIB1 天前
【字符编码】有无BOM的UTF-8
c++
Chary20161 天前
opengl 学习资料路径
c++·opengl
zhongvv1 天前
对单片机C语言指针的一些理解
c语言·数据结构·单片机·指针·汇编语言
im_AMBER1 天前
Leetcode 102 反转链表
数据结构·c++·学习·算法·leetcode·链表