VSCode c/c++多文件編譯環境配置(cmake+MinGW)


task.json:

{
    "version": "2.0.0",
    "options": {
        "cwd": "${workspaceRoot}/build"
    },/////////////////////////////////////////////////設置編譯啟動時路徑,將makefile保存到build路徑
    "tasks": [
        {
            "label": "cmake",
            "type": "shell",
            "command": "cmake",
            "args": [
                "-G",
                "MinGW Makefiles",
                ".."
            ],
        },
        {
            "label": "make",/////////////////////// make
            "type": "shell",
            "command": "mingw32-make",
            "args": [],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "dependsOn":["cmake"],
        },
    ]
}

  launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/bin/hello1",  //指定要調試的文件路徑
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "make" //////////////////////// 調試前先啟動make
        }
    ]
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM