# Building/Running 3D slicer with Slicer\_SUPERBUILD=OFF

**URL:** <https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502>\
**Category:** Development\
**Tags:** build\
**Created:** [April 3, 2018, 2:23pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502 "2018-04-03T14:23:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [April 3, 2018, 2:23pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/1 "2018-04-03T14:23:23Z")

</div>

Hi everyone,

I’ve managed to build 3DSlicer without the super-build mode by packaging/installing some of the underlying libraries for my Linux OS (Gentoo) and using some of the system libraries. After setting up the LD\_LIBRARY\_PATH and PYTHONPATH variables I’m able to start 3DSlicer but I get this error:

```auto
Traceback (most recent call last):
  File "/usr/lib/Slicer-4.8/qt-scripted-modules/DICOM.py", line 41, in __init__
    if slicer.mrmlScene.GetTagByClassName( "vtkMRMLScriptedModuleNode" ) != 'ScriptedModule':
AttributeError: 'vtkCommonCorePython.vtkObject' object has no attribute 'GetTagByClassName'
qSlicerPythonCppAPI::instantiateClass - ["DICOM"] - Failed to instantiate scripted pythonqt class "DICOM" 0x7fb2fd398db8 
Fail to instantiate module "DICOM" 

```

The symbol GetTagByClassName seems to have been built:

```auto
find -name "*.so" -exec nm --print-file-name {} \; | grep GetTagByClass

./bin/libMRMLCorePythonD.so:00000000001370e1 t _ZL32PyvtkMRMLScene_GetTagByClassNameP7_objectS0_
./bin/libMRMLCorePythonD.so: U _ZN12vtkMRMLScene17GetTagByClassNameEPKc
./bin/libqMRMLWidgets.so: U _ZN12vtkMRMLScene17GetTagByClassNameEPKc
./bin/libMRMLCore.so:0000000000550d0a T _ZN12vtkMRMLScene17GetTagByClassNameEPKc

```

Any ideas? Thanks in advance.

Best regards,  
Rafael Palomar

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 3, 2018, 3:43pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/2 "2018-04-03T15:43:11Z")

</div>

This indicates that the python-wrapped slicer libraries aren’t being loaded (perhaps they aren’t in the path where expected) so the MRML nodes, which are vtkObject subclasses, are only seen as vtkObjects. Maybe easiest would be to compare you build layout to a SuperBuild layout and see where the differences are. Either adjust the directory tree or the launcher paths should make it workable.

---

<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:** [April 3, 2018, 6:12pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/3 "2018-04-03T18:12:05Z")

</div>

> [@RafaelPalomar](#):
>
> build 3DSlicer without the super-build mode by packaging/installing some of the underlying libraries for my Linux OS (Gentoo) and using some of the system libraries.

### the “Slicer\_USE\_SYSTEM\_\<packageName\>” options

Not sure if this is something you already figure out but you can build Slicer by specifying `Slicer_USE_SYSTEM_<packageName>` option when configuring it for any of the project associated with an `External_<packageName>` found in the [SuperBuild](https://github.com/Slicer/Slicer/tree/master/SuperBuild) directory.

Looking at each individual `SuperBuild/External_*.cmake` file should also give some insight.

Using this approach will for example allow you to use VTKv9 on the system while ensuring the application launcher is downloaded and configured.

Also configuring with `Slicer_USE_SYSTEM_VTKv9` set to `ON` will also automatically require python to be on the system and ensure the launcher settings are configured accordingly.

To conclude:

- just starting Slicer using `bin/SlicerApp-real` is usually not recommended (unless you explicitly ensure the environment is correct).

- I would also recommend against setting `Slicer_USE_SUPERBUILD` to `OFF`, instead prefer setting the `Slicer_USE_SYSTEM_*` options

---

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [April 4, 2018, 7:00am UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/4 "2018-04-04T07:00:29Z")

</div>

Thank you @pieper and @jcfr for the tips. I’ll explore the alternatives you proposed; hopefully I can come up with a solution and post it here.

Best,  
Rafael.

---

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [November 2, 2018, 12:11pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/5 "2018-11-02T12:11:59Z")

</div>

Hello,

I managed to build the packages in the superbuilld separately and get them installed. Then I also got 3D Slicer to build using the system libraries (I still have Slicer\_USE\_SUPERBUILD=OFF…having a superbuild was problematic for installing the packages). Now I am at the point where all dependences are installed in their own directory in /usr/lib64, in addition, 3D Slicer is installed in /usr.

Now the problem I’m facing is that when launching 3D Slicer (it does not matter if I use the launcher or just SlicerApp-real), required .so and .py libraries are not found. The problem is gone if I manually set PYTHONPATH and LD\_LIBRARY\_PATH.

Do you have any ideas on how to preserve the installation RPATH when building 3D Slicer?

Thanks in advance!

Best,  
Rafael.

---

<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:** [November 2, 2018, 3:05pm UTC](https://discourse.slicer.org/t/building-running-3d-slicer-with-slicer-superbuild-off/2502/6 "2018-11-02T15:05:31Z")

</div>

Thanks for the update 👍

### make install with superbuild

> having a superbuild was problematic for installing the packages

You could run `make install` from `Slicer-SuperBuild/Slicer-build`

### RPATH

> preserve the installation RPATH when building 3D Slicer?

I suggest you look at [Verifying connection...](https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling)

### PYTHONPATH

> I manually set PYTHONPATH

The launcher settings are used by both the launcher and the application to set env. variable. For example, in a macOS package, the launcher settings are used. That way settings are consistently manage.

The same could be done on Linux.

If not already read by the launcher, here is where the launcher settings are loaded from the application:

[https://github.com/Slicer/Slicer/blob/01c28f0e8fbd2c169053a4a82af490f19c43b9ac/Base/QTCore/qSlicerCoreApplication.cxx#L237-L243](https://github.com/Slicer/Slicer/blob/01c28f0e8fbd2c169053a4a82af490f19c43b9ac/Base/QTCore/qSlicerCoreApplication.cxx#L237-L243)

Based on where the settings are installed on the system, we should tweak the following code:

[https://github.com/Slicer/Slicer/blob/01c28f0e8fbd2c169053a4a82af490f19c43b9ac/Base/QTCore/qSlicerCoreApplication.cxx#L1161-L1173](https://github.com/Slicer/Slicer/blob/01c28f0e8fbd2c169053a4a82af490f19c43b9ac/Base/QTCore/qSlicerCoreApplication.cxx#L1161-L1173)
