环境搭建--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"
		}
	]
}
相关推荐
从此不归路1 小时前
FPGA 结构与 CAD 设计(第3章)下
ide·fpga开发
云堆客栈2 小时前
基于vscode的markdown编辑器部署方案
ide·vscode·编辑器
smileNicky2 小时前
Lombok @Data 在 IDEA 中运行报错解决方案
java·ide·intellij-idea
好大哥呀2 小时前
C++ IDE
开发语言·c++·ide
OpenMiniServer2 小时前
AI + GitLab + VSCode:下一代开发工作流的革命性集成
人工智能·vscode·gitlab
滑稽的3 小时前
sublime merge汉化
编辑器·sublime text
dust_and_stars3 小时前
ubuntu24 安装vscode
ide·vscode·编辑器
向上的车轮3 小时前
如何选择Python IDE?
开发语言·ide·python
Destiny_where3 小时前
Claude VSCode插件版接入强大的GLM(无需登录注册claude code)
ide·人工智能·vscode·编辑器·claude code
猫头虎4 小时前
Claude Code 2026 年1月9日迎来大更新:Agent 能力增强(2.1.0 详解 + 升级指南)
ide·人工智能·macos·langchain·编辑器·aigc·ai编程