win10 下vscode配置c++编程

参考视频教程:Visual Studio Code安装配置C/C++教程,VSCode调试教程,VSCode安装使用教程,VSCode配置c/c++_哔哩哔哩_bilibili

离线安装所需要的文件整理如下:

链接:https://pan.baidu.com/s/1Bm1iEOexyWmCi0gQwID7tg

提取码:53ft


步骤一:下载并安装vscode,安装相关插件。

为了便于离线安装,我把相关软件和插件整理好在百度云中共享。

**vscode: 链接:**https://pan.baidu.com/s/1ZKlDnaiX3ehM9M0iB6aDFw 提取码:xjh8

vscode配置c++需要的插件:链接:https://pan.baidu.com/s/14xNJOwOMLaL6fzrZlSTf9g 提取码:3ps2

步骤二:下载MinGW。把MinGW解压后得到的bin文件夹添加到系统路径中。

MinGW-x86_64-8.1.0 : 链接:https://pan.baidu.com/s/1PuMBXQ9A7mIbaXfPEYBoSQ

提取码:mnta

备注:推荐使用这个版本,更高版本中不包含gbd.exe,会带来额外的麻烦。

步骤三:配置task.json和launch.json。

这两个配置文件自动生成,只需要修改对应的几行代码即可。

说明:

**task.json文件:**用于指定C/C++的编译(build)工具,其中C语言文件用gcc.exe编译, C++文件用g++.exe编译。gcc.exe和g++.exe都位于MinGW/bin文件夹中。

**launch.json文件:**用于指定C/C++的debug工具,C和C++都用gdb.exe进行debug.(在MinGW-8.1.0之后的版本,bin文件夹中不包含gdb.exe程序了,因此本文推荐使用MinGW-8.1.0)

task.json和launch.json文件的内容和需要修改的位置如下:

task.json ## 需要修改的位置我用注释标注了,个人认为,其实这里不用进行修改。

cpp 复制代码
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "E:\\software-setups\\MinGW\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                // "${file}",
                "*.c",//第一处需要修改的地方;当前文件夹所有的.c文件都编译
                "-o",
                // "${fileDirname}\\${fileBasenameNoExtension}.exe"//生成的执行程序名称
                "${fileDirname}\\a.exe"//第二处需要修改的地方:生成的执行程序名称//实际上此处可以不用修改
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

launch.json文件的内容及修改的位置见下

cpp 复制代码
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            // "program": "enter program name, for example ${workspaceFolder}/a.exe",//输入程序名
            "program": "${fileDirname}\\a.exe",//第一处需要修改的地方:输入程序名//实际上此处可以不用修改
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\software-setups\\MinGW\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",//第二处需要修改的地方:输入gdb的路径,在mingw/bin文件夹下
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}
相关推荐
会周易的程序员2 小时前
5Draft(五帝)测试报告
服务器·c++·分布式·raft·共识算法·共识·算力服务器
UIU1142 小时前
scanf与cout的误区:探究其内部的机制
c++·学习·c#·scanf
闻缺陷则喜何志丹2 小时前
【栈 运算系统】P3719 [AHOI2017初中组] rexp|普及+
c++·算法··洛谷·运算系统
bnmoel2 小时前
C++ 基础入门篇(一):命名空间,输入&输出,缺省参数,函数重载
c++·函数重载·语法·命名空间·缺省参数
Zixhy3 小时前
多点巡检机器人项目技术总结
linux·c++·机器人·自动驾驶
Pointer Pursuit4 小时前
C++11特性(二)
前端·c++·算法
tudousisi2225 小时前
CSP 第3题训练 Day 5|CSP202509C HTTP 头信息|Blog A
c++
闻缺陷则喜何志丹6 小时前
【动态规划】P10726 [GESP202406 八级] 空间跳跃|普及+
c++·算法·动态规划·洛谷
Chester_19996 小时前
CSP202312C.树上搜索
开发语言·数据结构·c++·蓝桥杯·stl
心平气和量大福大7 小时前
android studio(AS)工具-调试-统计总行数
android·ide·android studio