VScode环境配置及安装使用eigen3

引言

最近开始接触C和C++,代码调试的首要任务是配置执行环境,简单来讲VScode能够对C或者C++进行调试,就是项目文件夹中要包含.vscode文件夹。如果没有该文件夹可以进行创建,其中包含如下三个文件:
.vscode需要包含的文件
我将自己的.vscode文件夹中内容公布如下:

内容1. c_cpp_properties.json

{"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceRoot}",
            "D:/mingw64/include/**",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
            "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "__GNUC__=6",
            "__cdecl=__attribute__((__cdecl__))"
        ],
        "intelliSenseMode": "msvc-x64",
        "browse": {
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": "",
            "path": [
                "${workspaceRoot}",
                "D:/mingw64/include/**",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
                "D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
            ]
        }
    }
],
"version": 4
}

内容2. launch.json

{"version": "0.2.0",
"configurations": [
    {
        "name": "(Windows) Launch",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "cmd",
        "preLaunchTask": "echo",
        "args": [
            "/C",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "&",
            "echo.",
            "&",
            "pause"
        ],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole":true
    },
    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        // "externalConsole": true,
        // "console": "externalTerminal",
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
        "preLaunchTask": "echo",//这里和task.json的label相对应
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]

    }
]
}

内容3. tasks.json

    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    {"version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", 
                "${file}", 
                "-o", 
                "${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"//解决中文乱码
            ]
        }
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared", 
        "showReuseMessage": true,
        "clear": false
    }
}

备注:这三个代码块是在我的机器上能够运行的。有需要的朋友要根据自己mingw64的安装位置和migen3的安装位置对上述三个配置文件进行路径的修改。

migen3的安装使用:

migen3下载很方便,下载后解压放到相应位置,在.vscode三个文件中对路径进行引用即可。

后记:

万丈高楼平地起。积少成多,汇流成河。欢迎各位朋友在评论区留言讨论。

你可能感兴趣的:(vscode,c++,ide)