Instructions to compile and install vtk from sources on a Linux machine

To get VTK libraries running within Qt 5 from sources is not so hard. This is a quick reference guide to do so.

What’s needed:

  • linux machine (I use Ubuntu 18.04)
  • last vtk sources (tested with sources vtk 8.1)
  • Qt5 IDE (at the time of writing, I suggest to use 5.12.6 LTS version)
  • Qt Creator
  • CMake

Qt IDE is quite easy to install. I suggest to use latest Qt version (just use the online installer)

Before compilation just be sure to have all libraries installed:

  • sudo apt-get install build-essential libgl1-mesa-dev

Download VTK source code:

  • wget
  • wget
  • tar VTKData-8.1.0.tar.gz and copy md5 to VTK-8.1.0/build/ExternalData/Objects/MD5

then extract:

  • cd VTK-8.1.0
  • mkdir build
  • cd build
  • cmake-gui ..

Be sure to have some options flag active:

  • VTK_Group_Qt ON
  • QT5_DIR /opt/qt/5.12.6/gcc_64/lib/cmake/Qt5

Now you can build and install to directory chosen (i.e. /usr/local/include/vtk-8.1 and /usr/local/lib/cmake/vtk-8.1) :

  • make -j8
  • sudo make-j8 install

Install QVTKWidget plugin by copying to the install path: /usr/lib/x86_64-linux-gnu/qt5/plugins/designer


  • cd build/lib
  • ls -al
  • sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/designer
  • check available plugins: ls /usr/lib/x86_64-linux-gnu/qt5/plugins/designer (it should output a list)

Now in QT Creator you should have QVTKWidget:

You can use then the widget to design your application. By the way, this has been deprecated and you should use QVTKOpenGLWidget instead. You can promote to this the existing widget.

In main don’t forget to set QSurfaceFormat by adding : QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());

This is all. Now you can use full vtk power to design your 3d application !