win 10 中 vs code配置C++环境

mingw64下载安装

下载地址: https://sourceforge.net/projects/mingw-w64/files/
下滑找到:
其中x86_64指64位操作系统,i686指32位操作系统,win32是windows系统程序协议,posix是其他系统协议,seh仅支持64位操作系统,sjlj 32位64位都支持,dwarf仅支持32位。

下载好后解压到自定义路径(我是直接解压到D盘中的MinGW文件夹,并将解压后的文件重命名为mingw64),然后将mingw64的路径添加到系统变量。
完成后可在终端输入gcc,g++测试是否配置成功。

VS code配置C++环境

3个配置文件,c_cpp_properties.json,launch.json,tasks.json。
本人在launch.json中配置了两个启动,不需要debug时用(Windows) 启动(快一些),需要debug时用(gdb) 启动。编译好的程序都在中间文件夹temp中。

1, c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "D:\\MinGW\\mingw64\\bin\\g++",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}
2, launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) 启动",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "cmd",
            "preLaunchTask": "build",
            "args": [
                "/C",
                "${workspaceFolder}\\temp\\${fileBasenameNoExtension}"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "console": "externalTerminal"
        },

        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}\\temp\\${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\MinGW\\mingw64\\bin\\gdb.exe",
            "preLaunchTask": "build",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}
3, tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${workspaceFolder}\\temp\\${fileBasenameNoExtension}",
            ]
        }       
    ]
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值