Slicer for Ubuntu arm64

Notes on compilation efforts for compiling Slicer for arm64:

Problem: VTK does not compile.

  • In <SlicerDir>/SuperBuild/External_VTK.cmake remove section that has -DModule_vtkGUISupportQtOpenGL:BOOL=ON in it
  • Edit QVTKOpenGLNativeWidget.cxx to use QOpenGLExtraFunctions instead of QOpenGLFunctions_3_2_Core

Problem: CTKAPPLAUNCHER is a download of amd64
Solution: Overwrite executable <Slicer-build>/CTKAPPLAUNCHER/bin/CTKAppLauncher with compiled executable from <Slicer-build>/CTKAppLauncherLib-build/bin/CTKAppLauncher

1 Like

Thanks for the report.

Could you describe here:

  • how you setup the build environment / toolchain ?
  • in addition of the change described above, build options used ?

This would help improve the build system.

To enable others to reproduce the build, do you think a docker image could be added to ?

For sure, I’m expect it to be a slog, so this post is just for my notes as well as other googlers. Build options are all default unless a note is present in the main post.

To enable others to reproduce the build, do you think a docker image could be added to ?

Of course, how can I create a docker image?

Platform is FriendlyDesktop for NanoPC-T4.

Qt 5.10.0, provided in image.
qtchooser cleaned up:

pi@NanoPC-T4:~/devel/S4R$ qtchooser -qt=5.10 -print-env

CMake 3.14.1 built from source (make && sudo make install)


Using built-in specs.
Target: aarch64-linux-gnu
Configured with: …/src/configure -v --with-pkgversion=‘Ubuntu/Linaro 7.3.0-27ubuntu1~18.04’ --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04)

Problem: CTK fails to build

  • QtOpenGLTimeMonitor is not available under GL ES2 (at least in 5.10.0)

PythonQt version under Slicer does not support OpenGL ES build.

Workaround by manually removing non-OpenGL ES classes. Future fix upgrade PythonQt version.

Once I built Slicer on arm32. Please see here. I 'm surprised it 's so hard for arm64. Unfortunately, I don 't have any arm64 machine and can 't join in this effort. Good luck.

With OpenGL (ES) hardware acceleration?

I doubt it, didn 't even pay attention to that. The build was not usable in practice, VTK GPU rendering did not work, even the slices were not shown in the views. I 'll try a new build paying attention to OpenGL ES some weekend.

Yeah, that’s the kicker. I’m looking to produce a usable Slicer, hopefully.

For VTK, enable VTK_USE_SYSTEM_PNG, otherwise VTK builds libpng with NEON enabled.

Problem: libarchive fails to build
Solution: Add #include <sys/sysmacros.h> to <SlicerBuild>/LibArchive/libarchive/archive_pack_dev.c

Problem: zlib relocation errors
Solution: where present, use system zlib (via CMAKE_USE_SYSTEM_ZLIB, USE_BUILTIN_ZLIB, Slicer_USE_SYSTEM_zlib depending on project)

Problem: python-setuptools fails

/opt/dev/S4R/python-install/bin/PythonSlicer: 5: /opt/dev/S4R/python-install/bin/PythonSlicer: Syntax error: Unterminated quoted string

CMake Error at /opt/dev/S4/CMake/ExternalProjectForNonCMakeProject.cmake:104 (message):
  python-setuptools: bootstrap step failed with exit code '2'.

Solution: Just another effect of CTKAppLauncher being the wrong architecture. See solution for CTKAPPLAUNCHER is a download of amd64

Problem : CTK fails to build
PythonQt version under Slicer does not support OpenGL ES build.

  • QtOpenGLTimeMonitor is not available under GL ES2 (at least in 5.10.0)

Solution :
In CTK/CMakeExternals/PythonQt.cmake:34, remove gui from the list of wrapped modules

Set OpenGL_GL_PREFERENCE:STRING="GLVND" in PythonQt project

My setup did not have Qt Designer built, so I disabled designer plugins in CTK.

SimpleITK compilation crashes (NanoPC-T4, 4GB ram, gcc 7.3)

Disable SimpleITK
Possibly cross-compile if it’s a memory issue?

Disable all designer plugins for Slicer if designer is not available. -DSlicer_BUILD_QT_DESIGNER_PLUGINS:BOOL=OFF

Slicer wants vtkGUISupportQtOpenGL, see if workaround vtkGUISupportQt is enough

Just for information

I rebuilt Slicer on Odroid XU4 with a 32-bit ARM CPU. A clean build succeeded with this cmake config line :

#! export is required for python to build here
export CFLAGS=-I/usr/include/tirpc
export CXXFLAGS=-I/usr/include/tirpc; cmake -DSlicer_VTK_VERSION_MAJOR:INT=8 -DQt5_DIR:PATH=/usr/lib/cmake/Qt5 -DSlicer_USE_PYTHONQT_WITH_OPENSSL:BOOL=0 -DBUILD_TESTING:BOOL=0 -DCMAKE_BUILD_TYPE:STRING=Release -DSlicer_USE_SimpleITK:BOOL=0 …/Slicer

With a quick test, only one functionality is missing : viewing slices in 2D slice views ! With or without mali drivers. Volume rendering, segmention models show up. Slice data is visible in the 3D view, in the zoom preview (bottom left) but not in the RYG views. Would it really be an OpenGL ES problem ? I won’t insist of course, was just an experiment.

Does that machine/setup have OpenGL drivers for the Mali? If so, that simplifies things tremendously. Otherwise your setup is doing Mesa (software) rendering.

Looks like no, OpenGL ES 3.1. Would you check your VTK build to see if VTK_USE_OPENGL_ES is ON?