Creating and building a Loadable Module: need help with an error

Operating system: Red Hat Linux 7.6
Slicer version: 4.10.2
Expected behavior: A successful build of a test program
Actual behavior:

I would like to create my own C++ application that calls Slicer
functions with the C++ API.

From my reading of the documentation, it appears that to do this
I need to create a Loadable Module. I attempted to do this using the
Extension Wizard Module in Slicer.

The steps I took were:

Click ‘Create Extension’

Named my extension ‘SlicerTest’
Used Type ‘default’
Destination: /home/jtilton/src/SlicerPrograms

Clicked ‘Add module to extension’

Named it ‘SlicerTest’
Type: loadable

Went to /home/jtilton/src/SlicerPrograms/SlicerTest/SlicerTest

mkdir build cd build
$ cmake …

Got the error:
CMake Error at Logic/CMakeLists.txt:20 (SlicerMacroBuildModuleLogic):
Unknown CMake command “SlicerMacroBuildModuleLogic”.

Where did I go wrong?

Am I completely off base, or did I just miss some small thing?

Hi James,

To build a loadable module (which is a plugin that can be loaded by Slicer), you need to first have a build tree of Slicer.

You will then configure the SlicerTest module passing -DSlicer_DIR:PATH=/path/to/Slicer-build/Slicer-build

Once the module is built, the build tree will have a folder of the form /path/to/SlicerTest-build/lib/Slicer-4.11/qt-loadables-modules that contains the the plugin to be loaded.

This is the path to pass to Slicer using the additional-path option.

To save the trouble of passing option to Slicer, you should find a convenience launcher called “SlicerWithNameOfExtension” in the module build tree, starting this should be enough to start Slicer with you module loaded.

I suggest you read these two pages:

https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/BuildTestPackageDistributeExtensions

https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ/Extensions#How_to_build_an_extension_.3F

Hth

Jc

Thank you.

After I posted my questions, I found the instructions:

https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Module

But your instructions are clearer and more direct.

Jim Tilton

1 Like