many "undefined references" error in building vtk on raspberry pi 4

raspberry pi 4
OS: ubuntu 20
vtk source : 7.1.1
cmake version: 2.22

when I trying to build the vtk source on raspberry pi 4 I get lot of “undefined references” error on building the:
[ 5%] Linking CXX shared library ../../lib/libvtkCommonMath-7.1.so
is that possible to build vtk on raspberry pi 4 ?
I want to use the vtk on Qt.
how can I do that ? and build the vtk ?

cmake version: 2.22

Did you mean cmake 3.22?

In order to build VTK, several dev packages are required. I’m not sure what the complete list is, but you can try installing these with apt-get:

The essential packages:

build-essential cmake

Various libraries:

libfreetype6-dev libfontconfig1-dev
libgl-dev libglu-dev
libx11-dev libxpm-dev libxt-dev x11proto-core-dev

Qt libraries:

libqt5opengl5-dev libqt5webkit5-dev libqt5x11extras5-dev qtbase5-dev qttools5-private-dev

Python libraries (if you use Python)

python3-dev python3-matplotlib python3-six python3-twisted

Edit: I removed some packages that VTK will build itself.

2 Likes

You might want to reconsider building large things (like VTK) on RPi, mostly because it takes longer than it has to, and it thrashes the SD card. It is possible to use CMake to build for RPi on your desktop using something called a toolchain file. It is not easy, and I haven’t done it in years.

That way you build VTK on your laptop and then move the built binaries over to the Pi.

This is a very old toolchain file I used years ago:

# CMAKE_SYSTEM_NAME may be set explicitly when first configuring a new build
# tree in order to enable cross compiling. In this case the CMAKE_SYSTEM_VERSION
# variable must also be set explicitly. I have found notes on StackOverflow that
# indicate that CMAKE_SYSTEM_VERSION should be the output of `uname -r`, other
# folks have just used `1`. That tends to make me think it doesn 't matter.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR arm)
# The CMAKE_SYSROOT content is passed to the compiler in the --sysroot flag, if
# supported. The path is also stripped from the RPATH/RUNPATH if necessary on
# installation. The CMAKE_SYSROOT is also used to prefix paths searched by the
# find_* commands.
# CMAKE_STAGING_PREFIX This variable may be set to a path to install to when
# cross -compiling. This can be useful if the path in CMAKE_SYSROOT is read-only,
# or otherwise should remain pristine. GNU compilers support `--sysroot ` so
# this is an important setting.
set(CMAKE_SYSROOT /home/rexthor/images/Temp)
set(CMAKE_STAGING_PREFIX /home/rexthor/images/DeleteThis)
set(tools /home/rexthor/opt/rpi-x-tools/arm-bcm2708/gcc -linaro -arm -linux -gnueabihf -raspbian -x64)
set(CMAKE_C_COMPILER ${tools}/bin/arm -linux -gnueabihf -gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/arm -linux -gnueabihf -c++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

@dgobbi
thank you so much for your help
I finally built vtk on raspberry pi with clone the git repo.
have a good day :smiling_face_with_three_hearts: :wave: