当前位置: 首页 > news >正文

Visual Studio Code配置c/c++环境

Visual Studio Code配置c/c++环境

  • 1.创建项目目录
  • 2.vscode打开项目目录
  • 3.项目中添加文件
  • 4.文件内容
  • 5.配置编译器
  • 6.配置构建任务
  • 7.配置调试设置

1.创建项目目录

d:\>mkdir d:\c语言项目\test01

2.vscode打开项目目录

在这里插入图片描述

3.项目中添加文件

在这里插入图片描述

4.文件内容

#include <iostream>
using namespace std;int main(){cout << "hello world" << endl;return 0;
}

在这里插入图片描述

5.配置编译器

快捷键:Ctrl+Shift+P --> 输入c++ --> 选中"C/C++:Edit Configurations (UI)"

在这里插入图片描述

修改配置 c_cpp_properties.json

在这里插入图片描述
在这里插入图片描述

// c_cpp_properties.json
{"configurations": [{"name": "windows-gcc-x64","includePath": ["${workspaceFolder}/**"],"compilerPath": "C:/tools/mingw64/bin/gcc.exe","cStandard": "${default}","cppStandard": "${default}","intelliSenseMode": "windows-gcc-x64","compilerArgs": [""]}],"version": 4
}

6.配置构建任务

快捷键:Ctrl+Shift+P --> 输入Task --> 选中"Tasks: Configure Default Build Task" --> 选中"C/C++: g++.exe 生成活动文件"

在这里插入图片描述
在这里插入图片描述

// task.json 文件内容展示
{"version": "2.0.0","tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "C:\\tools\\mingw64\\bin\\g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "编译器: C:\\tools\\mingw64\\bin\\g++.exe"}]
}

7.配置调试设置

修改调试配置文件 launch.json

"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",

调试测试 : 工具栏 “Run” --> “Start Debugging”

// launch.json
{"version": "0.2.0","configurations": [{"name": "C/C++ Runner: Debug Session","type": "cppdbg","request": "launch","args": [],"stopAtEntry": false,"externalConsole": true,"cwd": "d:/c语言项目/test01","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","MIMode": "gdb","miDebuggerPath": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]
}
http://www.lryc.cn/news/235934.html

相关文章:

  • 漏洞利用工具的编写
  • ChatGPT之父被OpenAI解雇
  • linux中利用fork复制进程,printf隐藏的缓冲区,写时拷贝技术,进程的逻辑地址与物理地址
  • java游戏制作-拼图游戏
  • 使用sklearn报AttributeError: ‘NoneType‘ object has no attribute ‘split‘
  • C++学习 --map
  • 基于Qt QList和QMap容器类示例
  • Flask学习一:概述
  • LeetCode:689. 三个无重叠子数组的最大和(dp C++)
  • Leetcode—206.反转链表【简单】
  • Linux - 内存 - 预留内存占用分析
  • Java学习之路 —— Java高级
  • git使用及常用命令
  • vue 学习 -- day36(分析工程结构)
  • SQL Injection
  • 【Go入门】 Go搭建一个Web服务器
  • VS 将 localhost访问改为ip访问
  • app使用
  • 【迅搜01】安装运行并测试XunSearch
  • Mac电脑VSCode配置PHP开发环境
  • SpirngBoot + Vue 前后端分离开发工具代码
  • 【数据结构初阶】单链表(附全部码源)
  • 数据治理入门
  • uniapp 微信小程序登录 新手专用 引入即可
  • PMCW体制雷达系列文章(4) – PMCW雷达之抗干扰
  • Gin框架源码解析
  • MacOS设置JAVA_HOME环境变量
  • 闭眼检测实现
  • 系列六、Java垃圾回收器主要有哪些?
  • 【7】Spring Boot 3 集成组件:缓存组件 spring cache + spring data redis