# TBB libs are not installed during Debug build

**URL:** <https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369>\
**Category:** Development\
**Created:** [January 9, 2022, 3:55pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369 "2022-01-09T15:55:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [January 9, 2022, 3:55pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/1 "2022-01-09T15:55:51Z")

</div>

Hi,

Currently Slicer 3D uses [TBB 2019 u9](https://github.com/oneapi-src/oneTBB/releases/tag/2019_U9) (the link to the [Slicer TBB external pkg](https://github.com/Slicer/Slicer/blob/4f1e6145ca84e46277e02c061d44e2139d84884e/SuperBuild/External_tbb.cmake#L14-L24)).

If you tak a looke at TBB assets for Window/Linux/Mac then you will notice that it uses different naming convention for release and debug libraries. Release libs are called `libtbb.so` and Debug `libtbb_debug.so`.

In the same time [SlicerBlockInstallTBB.cmake](https://github.com/Slicer/Slicer/blob/4f1e6145ca84e46277e02c061d44e2139d84884e/CMake/SlicerBlockInstallTBB.cmake#L14-L41) handles only Release mode. So if the Slicer is compiled with TBB in Debug mode then installed Slicer should not work as it is unable to load debug TBB.

I’m not sure but I propose to add something like (UNIX example):

```auto
#----------UNIX CASE--------------#
install(
  FILES
    ${TBB_LIB_DIR}/libtbb.so.2
    ${TBB_LIB_DIR}/libtbbmalloc.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_proxy.so.2
    CONFIGURATIONS Release
    DESTINATION ${TBB_INSTALL_LIB_DIR} COMPONENT Runtime)

install(
  FILES
    ${TBB_LIB_DIR}/libtbb_debug.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_debug.so.2
    ${TBB_LIB_DIR}/libtbbmalloc_proxy_debug.so.2
    CONFIGURATIONS Debug
    DESTINATION ${TBB_INSTALL_LIB_DIR} COMPONENT Runtime)

if (CMAKE_BUILD_TYPE EQUAL "Release")
  slicerStripInstalledLibrary(
    FILES
      "${TBB_INSTALL_LIB_DIR}/libtbb.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_proxy.so.2"
    COMPONENT Runtime)
else ()
  slicerStripInstalledLibrary(
    FILES
      "${TBB_INSTALL_LIB_DIR}/libtbb_debug.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_debug.so.2"
      "${TBB_INSTALL_LIB_DIR}/libtbbmalloc_proxy_debug.so.2"
    COMPONENT Runtime)
endif()

```

If this is ok I could implement it in PR

---

<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:** [January 9, 2022, 3:57pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/2 "2022-01-09T15:57:45Z")

</div>

That sounds reasonable to me. Thanks for digging into this 👍

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [January 12, 2022, 5:13pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/3 "2022-01-12T17:13:31Z")

</div>

[Submitted a PR](https://github.com/Slicer/Slicer/pull/6110)

I only tried to handle `Debug` and `Release` modes but cmake also supports [RelWithDebInfo and MinSizeRel](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html).  
I don’t Know whether Slicer uses these build types but I don’t have experience of working with `RelWithDebInfo` and `MinSizeRel` thus I don’t know what libraries they need (debug or release).

Anyway I could to try fix this PR to handle `RelWithDebInfo` and `MinSizeRel` if needed.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [January 12, 2022, 5:16pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/4 "2022-01-12T17:16:13Z")

</div>

> [@keri](#):
>
> So if the Slicer is compiled with TBB in Debug mode then installed Slicer should not work as it is unable to load debug TBB.

Can you describe how it doesn’t work? I’m sure others have built Slicer in debug mode, but there haven’t been any reports of things not working.

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [January 12, 2022, 5:42pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/5 "2022-01-12T17:42:00Z")

</div>

> [@jamesobutler](#):
>
> I’m sure others have built Slicer in debug mode, but there haven’t been any reports of things not working.

You are right but I’m talking about installation (and packaging) like executing commands (assuming Slicer is built):

```auto
cd Slicer-build
cpack -B ../..

```

If you have built Slicer in `Debug` mode then Slicer is linked against `libtbb_debug.so`. That means if you want to install Slicer then you need to install `libtbb_debug.so` but Slicer installs `libtbb.so` instead. Thus when you try to run installed Slicer you should see something like `libtbb_debug.so not found` (but you have `libtbb.so` in the installation folder) and the app must fails to start. This happened to me on Ubuntu 20.04.

The idea behind `cmake install` used by me in PR is taken [from cmake the example](https://cmake.org/cmake/help/latest/command/install.html#:~:text=install(TARGETS%20target%0A%20%20%20%20%20%20%20%20CONFIGURATIONS%20Debug%0A%20%20%20%20%20%20%20%20RUNTIME%20DESTINATION%20Debug/bin)%0Ainstall(TARGETS%20target%0A%20%20%20%20%20%20%20%20CONFIGURATIONS%20Release%0A%20%20%20%20%20%20%20%20RUNTIME%20DESTINATION%20Release/bin))

---

<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:** [January 12, 2022, 5:48pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/6 "2022-01-12T17:48:57Z")

</div>

Generally speaking you aren’t meant to be making packages of debug or other non-release builds - I believe some tools won’t allow it or it’s against the license to redistribute the debug libs. But I guess there might be times when you’d want to.

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [January 12, 2022, 5:53pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/7 "2022-01-12T17:53:13Z")

</div>

Yes, and in my case I usually work with SlicerCAT and Debug mode. I needed to check whether I’m able able to correctly package the app or not (are there any bugs in my installation scripts).

---

<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 2, 2022, 6:58pm UTC](https://discourse.slicer.org/t/tbb-libs-are-not-installed-during-debug-build/21369/8 "2022-06-02T18:58:00Z")

</div>

To follow up on this, TBB version has been updated from `2019_U9` to `2021.5.0`.  
See [https://github.com/Slicer/Slicer/pull/6405](https://github.com/Slicer/Slicer/pull/6405)

The install rules have also been tested to make sure tbb release libraries are packaged.

That said, Debug libraries are still excluded. To support this, we would need to set the list of exceptions in [SlicerFunctionInstallLibrary.cmake](https://github.com/Slicer/Slicer/blob/177f3b324247de4e77d4497cc9121fe37dd5b3f3/CMake/SlicerFunctionInstallLibrary.cmake#L97-L98) based on the build type by checking the value of `CMAKE_BUILD_TYPE` (only the case of single configuration generator).
