How to debug loadable module in visual studio?

I have compiled slicer through the source code. Then i created a module (C++) and compiled it using cmake to generate module.sln. I want to debug this module using visual studio. What should I do?

Should I add this module project to slicer’s source project? I found some documentation on python debugging, but no tutorials on C++ modules I do?

There is documentation about this (however it seems to be a bit outdated):
https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/Debug_Instructions#Using_Visual_Studio

Basically you need to start Visual Studio using the launcher:
.\S4D\Slicer-build\Slicer.exe --VisualStudio

If you want to debug your own extension then you’ll need to add AdditionalLauncherSettings. The way I open VS for debugging SlicerRT:
.\S4D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash --launcher-additional-settings ./SlicerRT_D/inner-build/AdditionalLauncherSettings.ini c:\d\_Extensions\SlicerRT_D\inner-build\SlicerRT.sln
It also opens the solution.

Then you need to set basically any project as startup, then set the command to
[superbuild_path]\Slicer-build\bin\Debug\SlicerApp-real.exe
then just start debugging.

2 Likes

@cpinter I’ve updated the instructions based on your comments.

2 Likes

Thanks @cpinter. I followed you tutorials, it works.