Categories
VTK

How to build VTK C++ Source C

Official building guide (a little bit out-dated)

VTK/Configure and Build

Prerequisites

  • CMake 3.15.0
  • Qt5.12.3 → msvc2015_64
  • Visual Studio 2017 Professional

Download VTK Source code

git clone https://github.com/Kitware/VTK.git

Use CMake configure and generate Visual Studio Project

  • Start CMake-GUI

  • Select the appropriate source (git repository) and the build directory (a separated empty folder)

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled.png

  • Then click the “Configure” button. CMake will ask you to select the generator the first time you press Configure instead of having a drop-down menu in the main dialog.

    • Select generator:”Visual Studio 2017″ and platform: “x64” then click “Finish”

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-1.png

  • Wait til configure finish (5 to 10 minutes)

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-2.png

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-3.png

Editing Entries

Enable Qt

  • Change value of “VTK_GROUP_ENABLE_Qt” from “DEFAULT” to “YES”

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-4.png

  • Add a new entry QT_QMAKE_EXECUTABLE:FILEPATH=<YourQtPath>qmake.exe

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-5.png

Enable OpenGL related modules (optional)

  • Change value of OpenGL related moubles
    • Change value of “VTK_ENABLE_VTK_opengl” from “DEFAULT” to “YES”

    • Change value of “VTK_ENABLE_VTK_RenderingContextOpenGL2” from “DEFAULT” to “YES”

      http://140.115.171.230/wp-content/uploads/2020/05/Untitled-6.png

Generate Visual Studio Project

  • Click “Configure” again and make sure all red-background entries disappeared.

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-7.png

  • Then click “Generate” and wait til generating done.

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-8.png

  • Click “Open Project” via Visual Studio 2017 and select “Build → Build Solution”

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-9.png

  • Wait till building done (about 20 minutes)

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-10.png

  • Check .dll you need in <YourBuildPath>\bin\Debug

    http://140.115.171.230/wp-content/uploads/2020/05/Untitled-11.png