————————– 2018.03.27 更新————————-

便携版已更新,点此获取便携版

已知BUG:中文目录无法正常调试

用于cpptools 0.15.0插件的配置文件更新

新的launch.json

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process {
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/Program Files (x86)/MinGW/bin/gdb.exe", // GDB的路径,注意替换成自己的路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}]
}

新的tasks.json

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process {
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"windows": {
"command": "g++",
"args": [
"-ggdb",
"\"${file}\"",
"--std=c++11",
"-o",
"\"${fileDirname}\\${fileBasenameNoExtension}.exe\""
]
}
}
]
}

懒得自己配置或自己配置出现不明问题的朋友可以点这里:

【VSCode】Windows下VSCode便携式c/c++环境

http://blog.csdn.net/c_duoduo/article/details/52083494

下载解压即可食用。

————————– 2017.06.10 更新 (已过时)————————-

便携版已更新,点此获取便携版

用于cpptools插件的配置文件更新

更新的launch.json

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.2.0",
"configurations": [{
"name": "C++ Launch (GDB)", // 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg", // 配置类型,这里只能为cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"targetArchitecture": "x86", // 生成目标架构,一般为x86或x64,可以为x86, arm, arm64, mips, x64, amd64, x86_64
"program": "${file}.exe", // 将要进行调试的程序的路径 "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应 "args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${fileDirname}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
"preLaunchTask": "g++"   // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
}]
}

更新的tasks.json

{
"version": "0.1.0",
"command": "g++",
"args": ["-g","${file}","-o","${file}.exe"], // 编译命令参数
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}

懒得自己配置或自己配置出现不明问题的朋友可以点这里:

【VSCode】Windows下VSCode便携式c/c++环境

http://blog.csdn.net/c_duoduo/article/details/52083494

下载解压即可食用。

————————– 以下是原文 ————————-

这篇文章为blackkitty记录在windows下使用vscode编译调试c/c++的详细过程

首先看效果

设置断点,变量监视,调用堆栈的查看

条件断点的使用:

下面是配置过程:

总体流程:

  1. 下载安装vscode
  2. 安装cpptools插件
  3. 安装编译、调试环境
  4. 修改vscode调试配置文件
  5. 完了

下载安装vscode

https://code.visualstudio.com/Download



点击下载自己喜欢的相应版本,绿色版解压即可食用

安装cpptools插件

打开vscode,按ctrl+e打开快速命令框,输入以下命令后等待

ext install cpptools

vscode在短暂的联网查找后会列出插件列表,如图:



点击箭头所指处的按钮安装插件,安装过程可能会有些慢耐心等待

安装完成后vscode会提示你重启vscode,此时重启即可

安装编译、调试环境

目前windows下调试仅支持 Cygwin 和 MinGW。

这里使用的是MinGW.

下面是MinGW的安装配置过程:

http://mingw.org/

进入官网点击右侧 Download Installer下载安装器

打开安装器点击install准备安装:

选择一个安装目录,默认为C:\MinGW这里选择的是A:\MinGW

点击Continue开始安装,安装过程需联网,若安装时提示error则需翻墙安装

安装过程很快,结束后Continue按钮恢复为可用状态,点击完成安装。



打开MinGW安装管理器进行进一步配置

注意这里gdb必选,否则无法调试



选中几个需要的项右键Make for Installation进行标记,其中gcc和g++为c和c++编译器

选择完全部想要安装的项后点击左上角Installation菜单下的Apply Changes应用修改,过程需联网,中间出现error可先继续,若最后失败则需翻墙更新,建议翻墙

然后配置系统环境变量path,这一步为必须

在 我的电脑 上右键 属性:

然后按照下面步骤做即可,注意最后新建的项要与之前MinGW安装位置相对应

修改vscode调试配置文件

再次打开vscode,注意配置系统环境变量path后重启一下vscode

注意vscode调试需要在打开的文件夹中进行

打开文件夹后,新建test.cpp进行输入代码测试:

如图示进入调试界面选择C++:



然后会在工作目录下的生成一个launch.json的启动配置文件:

使用下面代码替换该文件:

{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)", // 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg", // 配置类型,这里只能为cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"launchOptionType": "Local", // 调试器启动类型,这里只能为Local
"targetArchitecture": "x86", // 生成目标架构,一般为x86或x64,可以为x86, arm, arm64, mips, x64, amd64, x86_64
"program": "${file}.exe", // 将要进行调试的程序的路径
"miDebuggerPath":"a:\\MinGW\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应
"args": ["blackkitty", "1221", "# #"], // 程序调试时传递给程序的命令行参数,一般设为空即可
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceRoot}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
"preLaunchTask": "g++"   // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
}
]
}

注意miDebuggerPath要与MinGw的路径对应

替换后保存,然后切换至test.cpp,按F5进行调试,此时会弹出一个信息框要求你配置任务运行程序,点击它~



在这里随便选一个:

然后用下面代码替换:

{
"version": "0.1.0",
"command": "g++",
"args": ["-g","${file}","-o","${file}.exe"], // 编译命令参数
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}

保存一下,然后切换至test.cpp,再次按F5启动调试~

完了!

【VSCode】Windows下VSCode编译调试c/c++【更新 2018.03.27】的更多相关文章

  1. 【转载】Windows下VSCode编译调试c/c++

    懒得自己配置或自己配置出现不明问题的朋友可以点这里: [VSCode]Windows下VSCode便携式c/c++环境 http://blog.csdn.net/c_duoduo/article/de ...

  2. 【VSCode】Windows下VSCode编译调试c/c++【更新】

    便携版已更新,点此获取便携版 用于cpptools插件的配置文件更新 更新的launch.json // Available variables which can be used inside of ...

  3. 【转载】【VSCode】Windows下VSCode编译调试c/c++

    转载自:http://blog.csdn.net/c_duoduo/article/details/51615381 懒得自己配置或自己配置出现不明问题的朋友可以点这里: [VSCode]Window ...

  4. JAVA 基础开发环境 vscode 搭建 Windows下VSCode编译运行简单java

    JAVA 基础开发环境 vscode 搭建 来源 https://www.cnblogs.com/freewsf/p/7744728.html 对于使用 Visual Studio Code 的 Ja ...

  5. windows下vscode修复c++找不到头文件

    因为原博客太长将部分内容分开 vscode找不到头文件的问题是由于windows下vscode默认的编译器是微软的MSVC(vs使用的编译器)的头文件路径 如果你没有安装vs肯定会因为找不到头文件而报 ...

  6. 原创 C++应用程序在Windows下的编译、链接:第一部分 概述

    本文是对C++应用程序在Windows下的编译.链接的深入理解和分析,文章的目录如下: 我们先看第一章概述部分. 1概述 1.1编译工具简介 cl.exe是windows平台下的编译器,link.ex ...

  7. C++应用程序在Windows下的编译、链接(一)概述

    C++应用程序在Windows下的编译.链接(一)概述 本文是对C++应用程序在Windows下的编译.链接的深入理解和分析,文章的目录如下: 我们先看第一章概述部分. 1概述 1.1编译工具简介 c ...

  8. 设置 Quick-Cocos2d-x 在 Windows 下的编译环境

    http://cn.cocos2d-x.org/tutorial/show?id=1304 设置 Quick-Cocos2d-x 在 Windows 下的编译环境 Liao Yulei2014-08- ...

  9. 【FFmpeg】Windows下FFmpeg编译

    由于FFmpeg是基于Linux开发的开源项目,源代码和Windows下最常见的Visual Studio提供的C/C++编译器不兼容,因此它不能使用MSVC++编译,需要在Windows下配置一个类 ...

随机推荐

  1. Live Archive 训练题 2019/3/9

    7454 Parentheses A bracket is a punctuation mark, which is used in matched pairs, usually used withi ...

  2. PSP DAILY软件功能说明书

    PSP DAILY软件功能说明书 一.开发背景 你在完成了一周的软件工程作业后,需要提交一个PSP图表,里面有4项,如下所示: 1.本周PSP表格,包含每项任务的开始.中断.结束.最终时间,格式如下: ...

  3. U盘安装OSX

    1.插入U盘,磁盘工具,格式化U盘为Mac OS X拓展 (日志式): 2.去网站搜索recovery disk assistant,此文件大约1.1M,直接打开使用它制作启动盘,进度条完毕就完成了. ...

  4. Codeforces Beta Round #8 C. Looking for Order 状压dp

    题目链接: http://codeforces.com/problemset/problem/8/C C. Looking for Order time limit per test:4 second ...

  5. Codeforces Beta Round #14 (Div. 2) D. Two Paths 树的直径

    题目链接: http://codeforces.com/contest/14/problem/D D. Two Paths time limit per test2 secondsmemory lim ...

  6. URL相关Web APIs

    参考文档:MDN> Web API接口 > URLUtils MDN > Web API接口 > URL MDN > Web API接口 > Location MD ...

  7. (九) 使用Jmeter 做分布式压测 ;

    在使用Jmeter进行性能测试时,如果并发数比较大(比如最近项目需要支持1000并发),单台电脑的配置(CPU和内存)可能无法支持,这时可以使用Jmeter提供的分布式测试的功能. 一.Jmeter分 ...

  8. Python2 读取表格类型文件

    resp = My_Request_Get(xls_url) # My_Request_Get是我自己封装的请求函数,可修改为requests请求f = ]) nrows = table._dimnr ...

  9. 对Spark2.2.0文档的学习3-Spark Programming Guide

    Spark Programming Guide Link:http://spark.apache.org/docs/2.2.0/rdd-programming-guide.html 每个Spark A ...

  10. DIH增量、定时导入并检索数据--转载

    原文地址:http://www.ifunit.com/984/solr%E5%AD%A6%E4%B9%A0%EF%BC%88%E4%BA%94%EF%BC%89dih%E5%A2%9E%E9%87%8 ...