首页 > 解决方案 > 调试 CMake 项目 Visual Studio Code OSX

问题描述

我正在遵循https://medium.com/@dexterchan_44737/visual-studio-code-build-and-debug-ac-with-cmake-on-mac-os-7633bc59bf34的说明,但我没有成功。

我的项目文件夹如下所示:

c_cpp_properties.json
launch.json
tasks.json
build
-- ...
Challenges
--main.cpp
--CMakeLists.txt
CMakeLists.txt

我的一些文件是:

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

启动.json

{
    "version": "0.2.0",
    "configurations": [
        {

            "name": "(lldb) Iniciar",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/Challenges/DailyCoding_run",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "targetArchitecture": "x86_64",
            "externalConsole": false,
            "MIMode": "lldb"
        }
    ]
}

任务.json

{
    "version": "2.0.0",
    "type": "shell",
    "options": {
        "cwd": "${workspaceRoot}/build"
    },
    "tasks": [
        {
            "label": "cmake",
            "command": "cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug ..",
            "type": "shell",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "panel": "shared"
            }
        },
        {
            "label": "make",
            "command": "make -j 8",
            "type": "shell",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "panel": "shared"
            },
            "group": "build"
        }
    ]
}
  1. 我将项目构建为Tasks: Command Palette... > Run Build Task

  2. Start Debugging

它在断点处停止,但无法单击其他任何内容,因为没有回答(无法执行 Step Over、Step Into ...)

在此处输入图像描述

标签: c++macosvisual-studio-codemacos-catalina

解决方案


推荐阅读