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

**URL:** <https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149>\
**Category:** Development\
**Tags:** extensions-manager\
**Created:** [June 12, 2019, 10:21pm UTC](https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149 "2019-06-12T22:21:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesCTilton](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@JamesCTilton](https://discourse.slicer.org/u/JamesCTilton)\
**Post date:** [June 12, 2019, 10:21pm UTC](https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149/1 "2019-06-12T22:21:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 12, 2019, 10:53pm UTC](https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149/2 "2019-06-12T22:53:19Z")

</div>

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/Tutorials/BuildTestPackageDistributeExtensions)

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ/Extensions#How\_to\_build\_an\_extension\_.3F](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ/Extensions#How_to_build_an_extension_.3F)

Hth

Jc

---

<div class="post-metadata">

**Author:** ![JamesCTilton](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@JamesCTilton](https://discourse.slicer.org/u/JamesCTilton)\
**Post date:** [June 13, 2019, 12:07pm UTC](https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149/3 "2019-06-13T12:07:36Z")

</div>

Thank you.

After I posted my questions, I found the instructions:

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build\_Module](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Module)

But your instructions are clearer and more direct.

Jim Tilton

---

<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 19, 2020, 9:01am UTC](https://discourse.slicer.org/t/creating-and-building-a-loadable-module-need-help-with-an-error/7149/4 "2020-01-19T09:01:56Z")

</div>

@jcfr  
I have the same problem.  
I used the same operation as JamesCTilton to create the module  
I run command cmake -DSlicer\_DIR:PATH=C:\S4R\Slicer-build …/  
It still error:  
CMake Error at Logic/CMakeLists.txt:20 (SlicerMacroBuildModuleLogic):  
Unknown CMake command “SlicerMacroBuildModuleLogic”.

Am i miss something?
