Skip to content

Build Instructions VTK

Bernhard Froehler edited this page May 22, 2020 · 24 revisions

Up to Windows Build / Linux Build.

Getting the Source Code

  • Download the latest release source archive (.zip for VTK < 9 on Windows, tar.gz for all others) from VTK Downloads.
  • Extract archive to an arbitrary folder; the folder containing the CMakeLists.txt is referenced on this page as vtk-src-dir, this could e.g. be C:\Tools\vtk\VTK-8.2.0 on Windows or /home/developer/devel/vtk/src-8.2.0 on Linux. Note: On Windows, make sure that the full path you choose for vtk-src-dir (and vtk-bin-dir, see below) is not too long (recommendation: below 25 characters in total), otherwise you might see errors regarding the command line for moc being too long.

Configuration

  • Start CMake
  • Make sure the "Advanced" checkbox is ticked
  • Specify vtk-src-dir under "Where is the source code", and an arbitrary vtk-bin-dir (e.g. C:\Tools\vtk\bin-8.2.0) under "Where to build the binaries"
  • Press "Configure"
  • Press "Yes" when asked whether the build directory should be created.
  • When asked, specify the desired generator; e.g. "Visual Studio 14 2015" / "Visual Studio 15 2017" / "Visual Studio 16 2019" on Windows, or "Ninja" / "Unix Makefiles" on Linux; these generators are the ones that we use internally; choosing another generator should be no problem, but as we haven't tested them, you might encounter problems, if so please let us know!
  • Typically, leave "Use default native compilers" checked; choose "Specify native compilers" if you know what you're doing and you want to use a different compiler (which you will be required to select in a next step).
  • Depending on which version of VTK you are using, the options to set vary:

Configuration options for VTK < 9

  • Enable BUILD_SHARED_LIBS (should be enabled by default)
  • Enable Module_vtkGUISupportQt
  • Enable Module_vtkGUISupportQtOpenGL
  • Enable Module_vtkRenderingQt
  • Enable Module_vtkViewsQt
  • Optional: Enable Module_vtkRenderingOpenVR (if you plan to build the VR module; see also the OpenVR section in the respective info for your operating system in Building open_iA)
  • Consider what VTK_RENDERING_BACKEND to use (VTK < 9 only); typically, use "OpenGL2". If building open_iA <= 2018.05, or if you are working on a system with a driver only supporting old OpenGL versions (requirement for OpenGL2 is GL version 3.2 with the gpu_shader4 extension), e.g. on a VirtualBox or on a Linux system with Intel graphics card, set VTK_RENDERING_BACKEND to "OpenGL" (note that the "OpenGL" backend is only available in VTK <= 8.1.2).
  • Optional: Enable VTK_LEGACY_REMOVE (enable only if you are building open_iA >= 2018.12, or master/develop branches and have set OpenGL2 as VTK_RENDERING_BACKEND - older versions of open_iA require QVTKWidget(2), which is only available if legacy code is not removed)
  • Optional: Enable VTK_LEGACY_SILENT (do not set this flag on VTK 8.1.x, as it potentially causes build problems there)
  • Press "Configure" again.
  • You will probably receive Qt-related errors regarding version 4 of Qt not being found or a wrong version of Qt having been found. In that case, set VTK_Qt_VERSION to 5, and press "Configure" again.
  • You will probably receive an error message that Qt5_DIR couldn't be determined. In that case, set the Qt5_DIR variable to the version/buildtype/lib/cmake/Qt5 sub-directory of the Qt installation folder (with Qt 5.9.x and the Visual Studio 2015 64 bit build installed, this would be Qt-installation-dir/5.9/msvc2015_64/lib/cmake )
  • Press "Configure" again.
  • If you enabled OpenVR, you will receive an error regarding CMake not finding OpenVR. To fix this:
    • Download archive for the OpenVR SDK.
    • Extract the archive.
    • In the CMake window where you configure VTK:
      • Set OPENVR_ROOT_DIR to the base directory where you extracted the OpenVR SDK.

Configuration options for VTK >= 9

  • Enable BUILD_SHARED_LIBS (should be enabled by default)
  • Set VTK_MODULE_ENABLE_VTK_GUISupportQt to YES
  • Set VTK_MODULE_ENABLE_VTK_vtkRenderingQt to YES
  • Set VTK_MODULE_ENABLE_VTK_ViewsQt to YES
  • Set VTK_MODULE_ENABLE_VTK_RenderingOpenVR to YES (if you plan to build the VR module; see also the OpenVR section in the respective info for your operating system in Building open_iA)
  • Press "Configure" again.
  • You will probably receive an error message that Qt5_DIR couldn't be determined. In that case, set the Qt5_DIR variable to the version/buildtype/lib/cmake/Qt5 sub-directory of the Qt installation folder (with Qt 5.9.x and the Visual Studio 2015 64 bit build installed, this would be Qt-installation-dir/5.9/msvc2015_64/lib/cmake )
  • Press "Configure" again.
  • If you enabled OpenVR, you will receive an error regarding CMake not finding OpenVR. To fix this:
    • Download archive for the OpenVR SDK.
    • Extract the archive.
    • In the CMake window where you configure VTK:
      • Set OpenVR_INCLUDE_DIR to the headers subfolder of where you extracted the OpenVR archive.
      • Set OpenVR_LIBRARY to the respective file required for linking to the SDK; on Windows, this is the file lib/win64/openvr_api.lib inside the SDK, on Linux, this is the file bin/linux64/libopenvr_api.so (inside of where you extracted the OpenVR archive).

Finishing configuration

  • When using a "single-configuration" generator, such as "Ninja" or "Unix Makefiles", also set CMAKE_BUILD_TYPE to the build type you want to create (e.g., Debug if you plan to fix problems in open_iA, Release if you plan to use it productively and run long-running operations). For Visual Studio generators, you don't need to create/modify this setting (it is a multi-configuration generator, the option typically even will not exist).
  • Press "Configure" one last time; if there still are errors, the corresponding messages should give you a hint as to what to do to resolve them.
  • When there are no more errors, and "Configuring done" is shown at the bottom of the log, press "Generate".

Building

  • On Windows with Visual Studio:
    • Click "Open Project" (check carefully that it opens with the correct Visual Studio version in case you have multiple versions installed!), or open vtk.sln in vtk-bin-dir in Visual Studio
    • Build desired configuration(s) (for example Debug), e.g. via "Build"->"Build Solution", or multiple configurations at once via "Build"->"Batch Build".
  • On Unix/Linux:
    • Open a command line in vtk-bin-dir.
    • Depending on the chosen generator:
      • If "Unix Makefiles", run make -j 8 - the 8 specifies the number of parallel compilations, you can adapt that to better match the number of (virtual) processor cores in your computer
      • If "Ninja, run ninja

If there are any problems, check the respective troubleshooting section:

Navigation:

Clone this wiki locally