Interest to create Flatpak for 3D Slicer, have issue with GUISupportQtOpenGL not found


I want to create Flatpak for 3D Slicer.
Flatpak is a packaging and distributing desktop software on Linux.

I would like it to be submit to Flathub, an app store for Flatpak apps. Many Linux distros supported Flatpak. So I think it would be beneficial to package large software like 3D Slicer into Flatpak, it will make installing 3D Slicer quick and easy.

This is what I have been working on so far.

I build VTK 9.0.1 with the following flags,

> - -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2=YES
> - -DVTK_MODULE_ENABLE_VTK_RenderingFreeTypeFontConfig=YES
> - -DVTK_MODULE_ENABLE_VTK_FiltersExtraction=YES
> - -DVTK_MODULE_ENABLE_VTK_ImagingMorphological=YES
> - -DVTK_MODULE_ENABLE_VTK_ImagingStatistics=YES
> - -DVTK_MODULE_ENABLE_VTK_InteractionImage=YES
> - -DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2=YES
> - -DVTK_MODULE_ENABLE_VTK_TestingRendering=YES

And Slicer with this,

When building 3D Slicer, I got this error.
> -- Setting C++ standard
> -- Setting C++ standard - C++11
> -- The C compiler identification is GNU 10.2.0
> -- The CXX compiler identification is GNU 10.2.0
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working C compiler: /usr/bin/cc - skipped
> -- Detecting C compile features
> -- Detecting C compile features - done
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/c++ - skipped
> -- Detecting CXX compile features
> -- Detecting CXX compile features - done
> -- Checking if --no-as-needed linker flag is required
> -- Checking if --no-as-needed linker flag is required - yes
> -- Check if the system is big endian
> -- Searching 16 bit integer
> -- Looking for sys/types.h
> -- Looking for sys/types.h - found
> -- Looking for stdint.h
> -- Looking for stdint.h - found
> -- Looking for stddef.h
> -- Looking for stddef.h - found
> -- Check size of unsigned short
> -- Check size of unsigned short - done
> -- Searching 16 bit integer - Using unsigned short
> -- Check if the system is big endian - little endian
> -- Could NOT find Subversion (missing: Subversion_SVN_EXECUTABLE) 
> -- Found Git: /usr/bin/git  
> -- Found Patch: /usr/bin/patch  
> -- Configuring Slicer organization domain []
> -- Configuring Slicer organization name [NA-MIC]
> -- Configuring Slicer default home module [Welcome]
> -- Configuring Slicer default favorite modules [Data, Volumes, Models, Transforms, Markups, SegmentEditor]
> -- Configuring Slicer text of disclaimer at startup [Thank you for using %1!<br><br>This software is not intended for clinical use.]
> -- Configuring Slicer release type [Experimental]
> CMake Warning (dev) at CMake/SlicerMacroExtractRepositoryInfo.cmake:94 (message):
>   Skipping repository info extraction: directory [/run/build/Slicer] is not a
>   GIT or SVN checkout
> Call Stack (most recent call first):
>   CMake/SlicerVersion.cmake:55 (SlicerMacroExtractRepositoryInfo)
>   CMakeLists.txt:183 (include)
> This warning is for project developers.  Use -Wno-dev to suppress it.
> -- Configuring Slicer version [4.11.20210226-0000-00-00]
> -- Configuring Slicer revision [0]
> CMake Warning (dev) at CMake/SlicerMacroExtractRepositoryInfo.cmake:94 (message):
>   Skipping repository info extraction: directory [/run/build/Slicer] is not a
>   GIT or SVN checkout
> Call Stack (most recent call first):
>   CMake/SlicerVersion.cmake:99 (SlicerMacroExtractRepositoryInfo)
>   CMakeLists.txt:183 (include)
> This warning is for project developers.  Use -Wno-dev to suppress it.
> -- Checking to see if CXX compiler accepts flag -fdiagnostics-show-option
> -- Checking to see if CXX compiler accepts flag -fdiagnostics-show-option - yes
> -- Checking to see if CXX compiler accepts flag -Wl,--no-undefined
> -- Checking to see if CXX compiler accepts flag -Wl,--no-undefined - yes
> -- Checking to see if CXX compiler accepts flag -fstack-protector-all
> -- Checking to see if CXX compiler accepts flag -fstack-protector-all - yes
> -- Configuring VTK
> --   Slicer_VTK_RENDERING_BACKEND is OpenGL2
> --   Slicer_VTK_SMP_IMPLEMENTATION_TYPE is Sequential
> --   Slicer_VTK_VERSION_MAJOR is 8
> -- Looking for pthread.h
> -- Looking for pthread.h - found
> -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
> -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
> -- Looking for pthread_create in pthreads
> -- Looking for pthread_create in pthreads - not found
> -- Looking for pthread_create in pthread
> -- Looking for pthread_create in pthread - found
> -- Found Threads: TRUE  
> -- Configuring Slicer with Qt 5.15.2 (using modules: Core, Widgets, Multimedia, Network, OpenGL, PrintSupport, UiTools, Xml, XmlPatterns, Svg, Sql, WebEngine, WebEngineWidgets, WebChannel, Script, Test, )
> -- Setting QT_PLUGINS_DIR: /usr/lib/plugins
> -- Setting QT_BINARY_DIR: /usr/lib/bin
> -- 
> -- Forcing Slicer_USE_SYSTEM_QT to ON (Qt5_DIR [/usr/lib/x86_64-linux-gnu/cmake/Qt5] associated with a system location: /usr/lib/)
> -- 
> -- Setting ExternalData_OBJECT_STORES to '/run/build/Slicer/_flatpak_build/ExternalData/Objects'
> -- Configuring Slicer for [linux-amd64]
> -- Using system QT
> -- Found X11: /usr/include   
> -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/
> -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/ - found
> -- Looking for gethostbyname
> -- Looking for gethostbyname - found
> -- Looking for connect
> -- Looking for connect - found
> -- Looking for remove
> -- Looking for remove - found
> -- Looking for shmat
> -- Looking for shmat - found
> -- Looking for IceConnectionNumber in ICE
> -- Looking for IceConnectionNumber in ICE - found
> -- Found OpenGL: /usr/lib/x86_64-linux-gnu/  found components: OpenGL GLX 
> -- Found Python3: /usr/bin/python3.8 (found suitable version "3.8.7", minimum required is "3.8") found components: Interpreter Development.Module Development.Embed 
> -- Found FontConfig: /usr/lib/x86_64-linux-gnu/  
> CMake Error at CMakeLists.txt:813 (find_package):
>   Found package configuration file:
>     /app/lib/cmake/vtk-9.0/vtk-config.cmake
>   but it set VTK_FOUND to FALSE so package "VTK" is considered to be NOT
>   FOUND.  Reason given by package:
>   Could not find the VTK package with the following required components:
>   GUISupportQtOpenGL.
> -- Configuring incomplete, errors occurred!

It does not found GUISupportQtOpenGL. I assume that there are patch that were applied to when superbuild is enable to VTK that fix the issue?
For Flatpak, superbuild are difficult to package, since superbuild will try to download packages, it will fail because Flathub does not allow that.

Are there patch file (.patch) that I can use? I can manually patch it.

Relate? GUISupportQtOpenGL is deprecated in VTK9 · Issue #5339 · Slicer/Slicer · GitHub


Thank you for working on this, it will be awesome.

Why don’t you use Slicer’s superbuild to take care of downloading and building all dependencies?

Flathub (Flatpak store) does not allow network connection while building for the package to be reproducible. I can only download all package before hand.

OK, then we need to download git repositories of all projects in advance and then pass their path to Slicer so that it uses those instead of downloading them. It may be enough to just specify Slicer_…_GIT_REPOSITORY CMake variable to point to the local git repository for each project (VTK, ITK, … all 40 projects in the SuperBuild subfolder; and for the few projects listed in SuperBuild.cmake) and build Slicer normally.

I think that might work, will this be in the next 3D Slicer version?

I actually try to Flatpak Telesculptor too, but fail to build because superbuild method that need network. I need to hack around but unsuccessful.

Just successfully Flatpak Paraview, Paraview is easy because it does not use superbuild, pretty much self contain.

I do have graphical glitch in Paraview, this happen to Tomviz as well. Do you havesome clue?
left flatpak, right tomviz binary

Slicer superbuild does not need network connection if you download the git repositories in advance.

The rendering error is probably an issue in VTK (or maybe due to an error in your graphics driver). Report it to ParaView developers.

Where must I put the pre-download dependencies? Must it be unpack or kept as archive?

I agree with @lassoan. This can be really good for Linux users!

It might make sense to try to break the superbuild for this (Slicer_SUPERBUILD=OFF). I don’t know much about flatpacks, but if they provide a sandboxed environment, maybe the Slicer app launcher could be disabled in favor of the sandboxed environment.

I would not recommend to deviate too much from the standard build and runtime environment, because even if somebody finds the time to implement the changes once, it will be very hard to maintain it.

The main problem of requiring network access during superbuild can be resolved by downloading the git repositories in advance and passing them as build options. This does not require any change in Slicer. I would expect that we’ll need to figure out something for bundled Python packages, too (is it OK to download pre-built wheels?).

It is ok to download prebuild wheels as well.
Could you clarify where must the pre-download deps be? Must it be archive or unpack? What should their archive or folder name be?

To move forward, the following need to be done:

  1. support local download git repository
  2. support download the applauncher
  3. support local download and use of python wheels
  4. update remaining external project to support passing local directory
  5. support local download of remote dependencies download using Slicer_Remote_Add. (see here)
  6. configure Slicer with relevant variables

For (1) and (2), scripts are provided below.

For (3):

For (4), these external files need to be updated to allow passing local file path:

External_CTKResEdit.cmake  # Only used on windows

For (5), it should be easy to instrument the relevant CMake functions.

(1) download git repositories

Note: this is a partial list, we will likely have to update the build system to be more exhaustive

I suggest the following:

  • Checkout dependencies in local directory (script below should help)
  • Then, configure Slicer passing the following variables:

Here is a short script to help download dependencies:


set -eo pipefail

# See

PROG=$(basename $0)


# Dependencies associated with Slicer d234b7ee9 from 2021.03.17
# See

cat << EOF > ${slicer_git_dependencies_file}


# List of variable obtained by locally modifying "ExternalProject_SetIfNotDefined"
# Patch:
# diff --git a/CMake/ExternalProjectDependency.cmake b/CMake/ExternalProjectDependency.cmake
# index 0f775d3ff0..c9a77856de 100644
# --- a/CMake/ExternalProjectDependency.cmake
# +++ b/CMake/ExternalProjectDependency.cmake
# @@ -1055,6 +1055,7 @@ macro(ExternalProject_SetIfNotDefined var defaultvalue)
#      endif()
#      set(${var} "${defaultvalue}")
#    endif()
# +  message(STATUS "${var}=${${var}}")
#  endmacro()
#  #.rst:

# Collect project names
for entry in $(cat "${slicer_git_dependencies_file}" | grep "GIT_REPOSITORY"); do
  proj=$(echo ${entry} | cut -d= -f1 | cut -d_ -f2)
  repo=$(echo ${entry} | cut -d= -f2)
  sha=$(cat "${slicer_git_dependencies_file}" | grep ${proj}_GIT_TAG | cut -d= -f2)
  if [[ ! -d "${SLICER_DEPENDENCIES_DIR}/${proj}" ]]; then
    git clone ${repo} ${proj}
  (cd ${proj}; git fetch --tags origin; git reset --hard HEAD; git checkout ${sha})

# List of options to configure Slicer
for entry in $(cat "${slicer_git_dependencies_file}" | grep "GIT_REPOSITORY"); do
  varname=$(echo ${entry} | cut -d= -f1)
  proj=$(echo ${entry} | cut -d= -f1 | cut -d_ -f2)
  echo "-D${varname}=file://${local_path}"

(2) download launcher

Here are the steps:

  1. download launcher using script below
  2. configure Slicer passing option CTKAppLauncher_DIR

Option to pass (as of Slicer d234b7ee9 from 2021.03.17):




# Dependencies associated with Slicer d234b7ee9 from 2021.03.17
# See


curl -L#${launcher_version}/${name}.tar.gz -o  ${name}.tar.gz
tar -xzvf ${name}.tar.gz


launcher_version can be discovered looking at External_CTKAPPLAUNCHER.cmake#L24-L46

1 Like

Thanks for the help. It looks good, I have nothing to add, let me know if it ready to be test.