# How to debug loadable module in visual studio?

**URL:** <https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751>\
**Category:** Development\
**Created:** [January 9, 2020, 7:38am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751 "2020-01-09T07:38:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![leemoncn](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leemoncn/32/5706_2.png) [@leemoncn](https://discourse.slicer.org/u/leemoncn)\
**Post date:** [January 9, 2020, 7:38am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/1 "2020-01-09T07:38:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 9, 2020, 10:14am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/2 "2020-01-09T10:14:26Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 9, 2020, 5:05pm UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/3 "2020-01-09T17:05:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leemoncn](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leemoncn/32/5706_2.png) [@leemoncn](https://discourse.slicer.org/u/leemoncn)\
**Post date:** [January 10, 2020, 8:14am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/4 "2020-01-10T08:14:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PatrickR](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@PatrickR](https://discourse.slicer.org/u/PatrickR)\
**Post date:** [January 15, 2025, 7:23am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/5 "2025-01-15T07:23:35Z")

</div>

This may be related to my visual studio version (I am using 2022), but when I follow these instructions, my module is not available in slicer.

To fix this, I needed to copy the `--additional-module-paths` from `inner-build\SlicerWithMyExtensionLauncherSettings.ini` and add them as command arguments to my startup project.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 15, 2025, 11:36am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/6 "2025-01-15T11:36:14Z")

</div>

Which extension are you trying to debug? Is it a superbuild extension? It would help if we could talk about it as a concrete case.

---

<div class="post-metadata">

**Author:** ![PatrickR](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@PatrickR](https://discourse.slicer.org/u/PatrickR)\
**Post date:** [January 16, 2025, 10:22am UTC](https://discourse.slicer.org/t/how-to-debug-loadable-module-in-visual-studio/9751/7 "2025-01-16T10:22:15Z")

</div>

It is an internal development making some proprietary functionality available in Slicer. Unfortunately, I am not at liberty to share this.

I mainly posted this here, to document my finding, so that the next person having that same problem could benefit from it.
