环境搭建--vscode

vscode官网下载合适版本

安装vscode插件

安装 MinGW

配置环境变量

把安装目录D:\mingw64 配置在用户的环境变量path里即可
选择用户环境变量path

点确定保存后开启cmd输入g++,如提示no input files 则说明Mingw64 安装成功,如果提示'g++' 不是内部或外部命令,也不是可运行的程序或批处理文件则说明安装失败

配置 vscode

我的项目结构是这样的,incude文件夹下为.h文件 src文件夹下为.cpp文件

点击运行与调试

点击运行与调试---》G++(Windows)

打开launch.json

配置launch.json

cpp 复制代码
{
    "version": "0.2.0",//版本
    "configurations": [//配置
        {
            "name": "g++.exe build and debug active file",//名字
            "type": "cppdbg",
            "request": "launch",//要求
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",//
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true, //修改此项,让其弹出终端
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\SoftWare\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++" //修改此项
        }
    ]
}

点击运行与调试---》

选择Others

配置

cpp 复制代码
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "task g++", //修改此项
			"command": "D:\\SoftWare\\mingw64\\bin\\g++.exe",
			"args": [
				"-g",
				// "${file}",
				"${cwd}//src//*.cpp",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "D:\\SoftWare\\mingw64\\bin"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build"
		}
	]
}
相关推荐
先跑起来再说15 小时前
Git 入门到实战:一篇搞懂安装、命令、远程仓库与 IDEA 集成
ide·git·后端·elasticsearch·golang·intellij-idea
嵌入小生00717 小时前
标准IO---核心函数接口延续(嵌入式Linux)
c语言·vscode·vim·嵌入式·小白·标准io·函数接口
LYOBOYI12318 小时前
vscode界面美化
ide·vscode·编辑器
浔川python社19 小时前
关于浔川代码编辑器 v5.0 网页版上线时间的通知
编辑器
mailangduoduo1 天前
零基础教学连接远程服务器部署项目——VScode版本
服务器·pytorch·vscode·深度学习·ssh·gpu算力
浔川python社1 天前
浔川代码编辑器 v5.0 上线时间公布
编辑器
山峰哥1 天前
数据库工程与SQL调优——从索引策略到查询优化的深度实践
数据库·sql·性能优化·编辑器
Doro再努力1 天前
Vim 快速上手实操手册:从入门到生产环境实战
linux·编辑器·vim
Doro再努力1 天前
【Linux操作系统10】Makefile深度解析:从依赖推导到有效编译
android·linux·运维·服务器·编辑器·vim
骥龙1 天前
第六篇:AI平台篇 - 从Jupyter Notebook到生产级模型服务
ide·人工智能·jupyter