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
                }
            ]
        }

    ]
}
相关推荐
樱花落木兰6 小时前
Git 超全零基础教程|三区原理、全套命令、分支协作、冲突解决、IDEA 集成(面试必备)
ide·git·json·github
意法半导体STM326 小时前
【官方原创】LAT1695转换STM32CubeIDE工程到STM32CubeIDE for Visual Studio Code
vscode·stm32·单片机·嵌入式硬件
Molesidy6 小时前
【Embedded Development】基于VSCode+IAR插件的IAR工程开发环境的搭建
ide·vscode·编辑器
欧特克_Glodon7 小时前
OpenCV计算机视觉开发入门与实践<二十四>:几何变换之平移、缩放、旋转
c++·人工智能·opencv·计算机视觉
鱼很腾apoc7 小时前
【Linux】第13期 详解应用层协议HTTP+Cookie/Session+HTTPS
linux·服务器·c++·学习·http·https
charlie1145141918 小时前
deque、list 与 forward_list:vector 之外的三个选择
开发语言·数据结构·c++·list·开源项目
Escalating_xu8 小时前
【C++ string 上篇】从字符串基础到容量管理、迭代器与经典算法题
java·c++·算法
啦啦啦啦啦zzzz8 小时前
ET和LT详解
linux·运维·服务器·网络·c++·网络编程
yangshuo12818 小时前
用AI开发一个公网IP查询小工具:精准查询IDE/终端的真实出口IP(Python实战)
ide·人工智能·tcp/ip
skr爱码士8 小时前
10_Qt Designer 与 UI 文件(.ui 原理、uic 编译、动态加载)
c++·qt·ui·客户端