Best way to code and test changes on C++ modules

Hi everyone, I am new to Slicer and C++ development.

I have more experience with Python, and I have noticed that modifying a Python script after installation and restarting the software lets you see the change. Is there something similar for C++ (for example, is there a way to modify the C++ of the SlicerMainWindow and see the change without having to rebuild Slicer, in order to test it?

@randomizedid C++ code needs to be compiled and this cannot be avoided. qt-loadable-modules usually are not that time consuming when compiling them, if you can structure your development in this way you will experience shorter compilation times.

If you cannot structure your development in a qt-loadable-module, you can still speed up the building process. The Slicer building system is structured in many build targets. The default compilation is all, which will try to build everything (in practice, this will go through the files and check for changes, so it is not as time consuming as a fresh compilation…still, it takes a while). However, you can build a specific target (typically that part of Slicer where you have made changes; this should already avoid building code that is not related). There is even a /fast version of targets, which I believe won’t resolve dependencies (this can be risky if you don’t know what you are doing). Finally, you can use ccache (Speeding up Slicer builds with CCache and ccache tip in GNU/Linux systems — 3D Slicer documentation). I’m not sure ccache is available for Windows and MAC, but it is possible to use it on GNU/Linux systems.

1 Like