zoukankan      html  css  js  c++  java
  • C++ VS Code 环境配置

    1、安装MinGW/GCC编译器

    2、配置环境变量  比如 E:MinGWin;

    3、安装vscode

    在cmd/powershell,输入code . ,可以打开vscode

    4、安装vscode插件

    打开vscode,按ctrl+p打开快速命令框,输入以下命令后等待

    ext install cpptools
    

    下载安装插件C/C++、C++ Intellisense

    5、配置.vscode文件

    第一,打开vscode,打开文件夹,新建一个文件夹,起名字,比如vscode,新建一个文件,起名字,比如test.cpp

    #include <iostream>
    using namespace std;
    int main()
    {
        cout<<"Hello";
        system("pause");
        return 0;
    }

    第二,按ctrl+shift+d,点击那个带着红点的齿轮,选择C++(GDB/LLDB),选择default configuration ,然后会在.vscode目录下,生成一个launch.json的启动配置文件,修改如下:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb)Launch",
                "type":"cppdbg",
                "request": "launch",
                "program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",   //
                "args": [],	
                "stopAtEntry": false, 
                "cwd": "${workspaceRoot}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
                //miDebuggerPath是环境变量的路径,64位gdb.exe
                "preLaunchTask": "g++",	//
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    } 

    第三,再在文件夹中新建tasks.json文件

    {
        "version": "2.0.0",//版本号
        "command": "g++",
        "args": ["-g","${file}","-o","${fileBasenameNoExtension}.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
            }
        }
    }
    

    6、调试.cpp

    注:因为VS需要为每一个文件夹做单独配置,所以建议把.vscode文件夹放到你常用的文件夹的顶层,这样就不用重复配置了

     

  • 相关阅读:
    合并链表
    ImportError: cannot import name 'GMM' from 'sklearn.mixture'
    SyntaxError: invalid character in identifier
    在 jupyter notebook 中插入图片
    Atom 换行后删除前面空格,需要按2/4次退格键
    win10输入法InpuMode默认显示中文
    Visual Studio(WindowsSDK.targets(46,5): error MSB8036: 找不到 Windows SDK 版本8.1)
    atom修改注释的字体,字号,颜色
    '__int64' has not been declared
    VMware 打开虚拟机库
  • 原文地址:https://www.cnblogs.com/GoldenEllipsis/p/11485017.html
Copyright © 2011-2022 走看看