# Slicer packaging Qt5 libraries link

**URL:** https://discourse.slicer.org/t/slicer-packaging-qt5-libraries-link/3583
**Category:** Development
**Tags:** build
**Created:** [July 26, 2018, 1:37pm UTC](https://discourse.slicer.org/t/slicer-packaging-qt5-libraries-link/3583 "2018-07-26T13:37:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![juanprietob](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/juanprietob/32/6306_2.png) [@juanprietob](https://discourse.slicer.org/u/juanprietob)
#### Post date: [July 26, 2018, 1:37pm UTC](https://discourse.slicer.org/t/slicer-packaging-qt5-libraries-link/3583/1 "2018-07-26T13:37:18Z")

</div>

Operating system: MACOS 10.13.5  
Slicer version: 27287  
Expected behavior: Launch Slicer  
Actual behavior:

I have compiled Slicer r 27287 successfully on MACOS high Sierra 10.13.5  
The packaging seems to be working after the following fixes are introduced, otherwise errors such as appear for Qt libraries:

```
warning: cannot resolve item '@rpath/QtMultimedia.framework/Versions/5/QtMultimedia'

  possible problems:
    need more directories?
    need to use InstallRequiredSystemLibraries?
    run in install tree instead of build tree?

```

The fixes are  
Before calling configure\_file in SlicerCPack.cmake line 140 (this is to get the location of Qt5 libraries):

```
  get_target_property(Qt5_location Qt5::Widgets LOCATION)
  string(FIND ${Qt5_location} "/QtWidgets" length)
  string(SUBSTRING ${Qt5_location} 0 ${length} Qt5_location)

configure_file(
    "${Slicer_SOURCE_DIR}/CMake/SlicerCPackBundleFixup.cmake.in"
    "${slicer_cpack_bundle_fixup_directory}/SlicerCPackBundleFixup.cmake"
    @ONLY)

```

And in the SlicerCPackBundleFixup.cmake.in in line 314 (This is to add the location):

```
set(libs_path ${libs_path} @Qt5_location@)

fixup_bundle(
    "${app_dir}"
    "${libs}"
    "${libs_path}"
    )

```

The following error appears now:

```
dyld: Library not loaded: @rpath/Frameworks/QtMultimedia.framework/Versions/5/QtMultimedia
  Referenced from: /Users/aaaa/Slicer/Slicer-install/Slicer.app/Contents/MacOS/Slicer
  Reason: no suitable image found. Did find:
    /Users/aaaa/Slicer/Slicer-install/Slicer.app/Contents/MacOS/../Frameworks/QtMultimedia.framework/Versions/5/QtMultimedia: file too short
[1] 9262 abort /Users/aaaa/Slicer/Slicer-install/Slicer.app/Contents/MacOS/Slicer

```

Does any body know how to fix the packaging?

Thank you in advance.

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)
#### Post date: [July 26, 2018, 1:51pm UTC](https://discourse.slicer.org/t/slicer-packaging-qt5-libraries-link/3583/2 "2018-07-26T13:51:01Z")

</div>

Try this [solution](https://discourse.slicer.org/t/build-error-on-macosx-and-linux-with-itkpython-enabled/3277/19?u=alex_vergara)

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)
#### Post date: [July 26, 2018, 2:12pm UTC](https://discourse.slicer.org/t/slicer-packaging-qt5-libraries-link/3583/3 "2018-07-26T14:12:31Z")

</div>

@juanprietob Qt5 needs to be built with `-no-rpath` right now. See [this build script](https://github.com/jcfr/qt-easy-build/blob/5.10.0/Build-qt.sh#L359-L363).

> [@Alex\_Vergara](#):
>
> Try this [solution](https://discourse.slicer.org/t/build-error-on-macosx-and-linux-with-itkpython-enabled/3277/19)

That may work locally, but it is not a solution for packaging; users should not need to set any environment variables.
