环境搭建--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"
		}
	]
}
相关推荐
汤姆yu2 小时前
IDEA使用通义灵码做现有项目迭代开发保姆级教程
java·ide·intellij-idea·灵码
阴暗扭曲实习生2 小时前
135编辑器素材管理系统的技术架构
架构·编辑器
易水寒陈2 小时前
使用vscode开发stm32
ide·vscode·stm32
2501_915918413 小时前
有没有Xcode 替代方案?在快蝎 IDE 中完成 iOS 开发的过程
ide·vscode·ios·个人开发·xcode·swift·敏捷流程
温酒斟与你3 小时前
idea编辑器新版UI回归旧版
java·ide·intellij-idea
God__is__a__girl3 小时前
IntelliJ IDEA 启动失败问题解决记录
java·ide·intellij-idea
粤M温同学16 小时前
Android Studio 中安装 CodeBuddy AI助手
android·ide·android studio
学会放下ta17 小时前
安装breakpad
ide
山峰哥17 小时前
SQL优化实战:从索引策略到执行计划的极致突破
数据库·sql·性能优化·编辑器·深度优先
szcsun519 小时前
关于在pycharm中新建项目创建虚拟化环境venv
ide·python·pycharm