zoukankan      html  css  js  c++  java
  • VS Code编译C/C++

    如何让VSCode做C++开发的IDE?

    1.安装MINGW, 配置PATH

    编译器安装成功

    2.安装VS 插件

    在terminal调试下

    3.配置 launch.json, 项目根目录.vscode下。复制进去之后要修改miDebuggerPath参数,这里面填写自己的gdb.exe路径,编译配置已完成。

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${file}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceRoot}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "C:\MinGW\bin\gdb.exe",
                "preLaunchTask": "g++",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }
    

    4.Ctrl+Shift+P,输入Tasks:Configure Task,之后选择使用模板创建tasks.json文件, 同样保存在根目录.vscode下  

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "command": "g++",
        "args": ["-g","${file}","-o","${file}.exe"],    // 编译命令
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["relative", "${workspaceRoot}"],
            "pattern": {
                "regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
    

      

    5. 按F5即可执行,如果console控制台只闪出来一下,不能观察到结果,解决办法是在return 0之前增加一句system("pause"),缺点在于每个文件都要写,不知道有没有更好的办法。

    参考: https://blog.csdn.net/qq_39630587/article/details/79826652

       https://www.zhihu.com/question/30315894 

  • 相关阅读:
    SDOI 2016 数字配对
    SDOI 2016 征途 决策单调性
    SDOI 2016 生成魔咒
    SDOI 2016 排列计数
    【SC主题公园杯】三个袋子 = =不动脑的后果
    【BZOJ3050】【USACO 2013 Jan Gold金组】坐座位 Seating
    MillerRabin 快速的素数概率判定法
    [POJ3189][cqbzoj1640]稳定的奶牛分配 解题报告
    最大流 isap 模板
    【POJ 1324】Holedox Moving A*宽搜
  • 原文地址:https://www.cnblogs.com/7star/p/12566246.html
Copyright © 2011-2022 走看看