vscode 简单配置mingw64

  1. 把mingw64添加环境变量,mingw-64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin

  2. ctrl+r 打开cmd 输入 gcc-v 回车

  3. C:\Users\chade>md cplusplus-project 
    C:\Users\chade>cd cplusplus-project 
    C:\Users\chade\cplusplus-project>code .
    
  4. 这时vscode应该已经打开,创建hello.cpp文件,确保打开的是当前文件,点击运行,点击打开配置,选择 gdb c++ 自动生成两个配置文件tasks.json launch.json

  • tasks.json 编译任务配置
  • launch.json 调试配置
  • c_cpp_properties.json c/c++ 编译版本配置
    https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
    5.创建helloc.c文件,点击菜单上的终端,再点击配置默认生成项目,自动打开tasks.json,就会多了gcc C/C++: gcc.exe build active file

更多配置可,ctrl + shift + b 输入c/c++

以下是自动生成的文件
task.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe"
        }
    ],
    "version": "2.0.0"
}

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\SoftwareDevelopmentEnvironment\\CPlusPlusSoftwareEnvironment\\mingw-64\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值