环境搭建--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"
		}
	]
}
相关推荐
Hi_kenyon1 小时前
Vscode的常用快捷键(摆脱鼠标计划)
ide·vscode·计算机外设
唯之为之4 小时前
如何快速无缝的从 vscode 转向AI编辑器 cursor、kiro、trae 等
vscode·ai编程
写写闲篇儿4 小时前
经典IDE之Turbo C
ide
Generalzy4 小时前
从 Print 到 Debug:用 PyCharm 掌控复杂程序的调试之道
ide·性能优化·pycharm
Kiri霧20 小时前
IntelliJ IDEA
java·ide·kotlin·intellij-idea
晨风先生21 小时前
如何Visual Studio 的配置从 Qt-Debug 切换到 x64-Debug
ide·qt·visual studio
要加油哦~1 天前
工具 | 解决 VSCode 中的 Delete CR 问题
ide·vscode·编辑器
未来之窗软件服务1 天前
基于 Nginx 与未来之窗防火墙构建下一代自建动态网络防护体系—仙盟创梦IDE
网络·ide·nginx·服务器安全·仙盟创梦ide·东方仙盟
yao000371 天前
Claude 4.0 终极编程指南:模型对比、API配置与IDE集成实战
ide·ai编程
我有一只肥螳螂1 天前
idea监控本地堆栈
java·ide·intellij-idea