# \[SOLVED\] CMake, VSCode and debugging?

**URL:** <https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838>\
**Category:** CMake\
**Created:** [January 25, 2022, 10:38am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838 "2022-01-25T10:38:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiza177](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@luiza177](https://forum.juce.com/u/luiza177)\
**Post date:** [January 25, 2022, 10:38am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/1 "2022-01-25T10:38:45Z")

</div>

I like using VSCode to do my coding as it feels less overwhelming than with IDEs like Visual Studio or XCode. As a beginner, perhaps I shouldn’t, but still… Either way, I’ve set up my `launch.json` and `tasks.json` as follows:

launch.json:

```auto
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      // "program": "/Applications/AudioPluginHost.app",
      "program": "${workspaceFolder}/build/SimpleEQ_artefacts/Standalone/SimpleEQ.app",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "lldb",
      "preLaunchTask": "build"
    }
  ]

```

and tasks.json

```auto
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "make",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "options": {
        "cwd": "${workspaceFolder}/build/"
      }
      
    }
  ]

```

I can’t seem however to be able to print stuff to console, either with `std::cout` or using the `DBG` macro. As for the `CMakeLists.txt` file, I’m simply using a slightly modified version of the [AudioPlugin example at github.](https://github.com/juce-framework/JUCE/blob/master/examples/CMake/AudioPlugin/CMakeLists.txt)  
I know I have to be missing something, but I’m not sure where to start looking, any help will be appreciated!

---

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [January 25, 2022, 10:47am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/2 "2022-01-25T10:47:04Z")

</div>

Have you installed the [C/C++ Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack)? I’ve found that after installing that pack, with the CMake extension I can easily debug a JUCE project using a `launch.json` file similar to the one provided here: [Target Debugging and Launching — CMake Tools 1.4.0 documentation](https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html)

That being said, I haven’t used vscode to debug a plugin so there may a missing step to get that working as expected… what host are you using?

---

<div class="post-metadata">

**Author:** ![luiza177](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@luiza177](https://forum.juce.com/u/luiza177)\
**Post date:** [January 25, 2022, 10:59am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/3 "2022-01-25T10:59:44Z")

</div>

I do have the C/C++ Extension Pack installed. I had the CMake Tools extension disabled though, I remember finding it rather cumbersome for reasons I no longer remember, but I should probably give that a try again, thanks for the link!

---

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [January 25, 2022, 11:18am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/4 "2022-01-25T11:18:00Z")

</div>

I struggled to get it to play nicely to start with too, but starting from scratch and following the various guides online I managed to get it working fairly well.

---

<div class="post-metadata">

**Author:** ![luiza177](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@luiza177](https://forum.juce.com/u/luiza177)\
**Post date:** [January 25, 2022, 11:58am UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/5 "2022-01-25T11:58:23Z")

</div>

I realized I originally copy-pasted the `tasks.json` file twice, I’ve edited to show the `launch.json` file now too. Also answering your question, I’m using the standalone version and JUCE’s AudioPluginHost.

---

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [January 25, 2022, 1:02pm UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/6 "2022-01-25T13:02:04Z")

</div>

My `launch.json` looks like this FWIW… I don’t have a `tasks.json`:

```auto
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    "name": "PATH",
                    "value": "$PATH:${command:cmake.launchTargetDirectory}"
                }
            ],
            "MIMode": "lldb",
            "logging": {
                "moduleLoad": false
            }
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![luiza177](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@luiza177](https://forum.juce.com/u/luiza177)\
**Post date:** [January 25, 2022, 1:29pm UTC](https://forum.juce.com/t/solved-cmake-vscode-and-debugging/49838/7 "2022-01-25T13:29:19Z")

</div>

I fixed it! All I had to do was add `set(CMAKE_BUILD_TYPE Debug)` in `CMakeLists.txt` (which of course would need to be set to Release when the time came), and then adjust the path in `launch.json` to

```auto
"program": "${workspaceFolder}/build/SimpleEQ_artefacts/Debug/Standalone/SimpleEQ.app"

```
