How to debug a plugin using Visual Studio (CMake)

I’m having trouble getting a VST3 plugin to run inside the VS Debugger. The plugin is built from a CMake project, and the auto-generated JSON configuration files aren’t finding the right target (the target in this case being the VST host).

Here is what I’ve done so far:

  1. Open the CMake folder and let Visual Studio auto-configure from the CMakeLists.txt file.
  2. Build the project. (The build was successful: I’ve tested it inside a DAW).
  3. Select “Add debug configuration” from the “CMake targets view” in Solution Manager. This generated a lanch.vs.json file (aka `launch_shema.json).
  4. Edited the "projectTarget" and "name" terms in that file to point them towards the VST host.

After these steps, I can start the debugger, but it just opens up an empty console window–not the desired VST host.

Here is the contents of my launch.vs.json file:

  "version": "0.2.1",
  "defaults": {},
  "configurations": [
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "Waveform 11 (64-bit).exe (C:\\Program Files\\Tracktion\\Waveform 11\\Waveform 11 (64-bit).exe)",
      "name": "Waveform 11 (64-bit).exe (C:\\Program Files\\Tracktion\\Waveform 11\\Waveform 11 (64-bit).exe)"

The situation is made more difficult because the target filename is "Waveform 11 (64-bit).exe"; I’m not sure if I should be escaping the brackets or the white spaces. However, nothing that I do to this file seems to make any difference–even if I break it by changing "configurations" to "configurationsxxxx", it still gives me the same console window, indicating that the file isn’t being read in the first place.

Does anyone have any suggestions?

I would like to know too.
I’m only able to debug VST targets after generating a VS solution using cmake -G "Visual Studio 16 2019" -S . -B build".

Opening with the ‘native’ VS CMake support only allows me to debug standalone targets - but it’s possible I’m missing something.

Would be interested in a solution too! Or if this is impossible for some reason, how does the workflow of other Windows developers using CMake for plugin development look like?


I’m stuck there too, trying to debug a VST3 plugin in a Visual Studio CMake project (derived from the JUCE examples/CMake/AudioPlugin folder).
For the standalone version I have a “Debug” option, this works fine (builds, launches the .exe and attaches to the debugger).

But not so for the VST3 version (which builds also fine):

(using VS2019 CE, JUCE latest development branch)

As mentioned above, you can generate a VS project using cmake -B cmake-build-vs2019 -G "Visual Studio 16 2019" -A x64. Then, launch a plugin host and select “Debug → Attach to Process…” to attach to the host process. After loading your plugin in the host, you should be able to debug your plugin, hit breakpoints etc.

I’m aware of that (actually that’s what I’ve done successfully there :)) but thing is perspectively I’d like to use a Git/CMake based cross-platform continous integration/auto-build workflow with that plugin that’s why I’m trying to stay with a CMake project (rather than doing a VS project).

So no chance currently to debug a VS/VST3/CMake project directly?

Yes you can. @reuk gave all the steps in his message. Please re-read it and let us know what is not clear.

When you generate a VS project with CMake, the CMake project keeps being your ‘master’ file with all the build information.

The generated VS Project is just a local file you use in your dev environment, and isn’t committed to source control.

While it is convenient to be able to open the CMake file directly without going through the generation steps, it has that missing feature of attaching to plugin targets as you mentioned, hopefully it’s fixed in VS 2022.

Now I’m slightly confused, as @mcmartin states it’s possible while you state it isn’t.
But I’ve investigated further a bit and would also think it isn’t currently (I know it’s possible doing it with a VST2/.dll) but the missing feature seems currently that it’s not possible to specify .vst3:
From the launch.vs.json schema reference (C++):

Thanks for the replies.

A question to your suggestion having the CMake project as ‘master’ and using The VS project for debugging:
That would mean when I add new source files I’d have to do it for both projects seperately, right?
(But other than that I think it’s a workable solution.)

There are two ways that I know of

  1. you can click debug->attach to process and attach to the host after you ran it. That would work even if you naturally open a CMake file.

  2. You can generate a VS solution as @reuk mentioned.
    After doing that you’ll notice the ‘solution explorer’ looks totally different.

Then you can:

  1. right click the VST3 target->preferences
  2. debugging->command->browse for your host exe
  3. right click the VST3 target->set as startup project.

You can then launch the host and attach automatically with F5/the green play icon.

No, you always make changes in the CMake project.
Whenever you make a change in the CMakeLists.txt file, just run the cmake command line again to generate a fresh IDE project.

You should never change things in the VS project directly (other than local debugging stuff like what we just talked about).

1 Like

Got it, makes sense. Thanks.