VTK can be installed by downloading the source, configuring with CMake, building in a separate directory, and linking the libraries to your development environment.Step 1: Obtain VTK Source
Download the latest VTK source code from the official GitLab repository using:
git clone https://gitlab.kitware.com/vtk/vtk.git
Alternatively, you can download a release archive (zip or tar.gz) from the VTK releases page .
Step 2: Prepare Dependencies
Ensure the following tools and libraries are installed:
- CMake (version 3.12 or newer) for configuration .
- C++ compiler (g++ on Linux, Visual Studio on Windows) .
- Optional libraries depending on features: Python (≥3.4), Qt, HDF5, MPI, ffmpeg .
Step 3: Create a Build Directory
VTK requires an out-of-source build. Create a separate directory for building:
mkdir /opt/VTK-buildcd /opt/VTK-build
This keeps the source directory clean and avoids in-source build issues .
Step 4: Configure with CMake
Run CMake to configure the build:
cmake /opt/VTK
- Use cmake-gui for a graphical interface or ccmake for terminal-based configuration.
- Set the source directory to the VTK source and the build directory to your build folder.
- Select the generator appropriate for your platform (Makefiles, Ninja, or Visual Studio) .
Step 5: Build VTK
Compile the source using your chosen build system:
make -j$(nproc)
- On Windows, build using Visual Studio or msbuild .
Step 6: Install VTK
After building, install the libraries and headers:
sudo make install
This typically installs files to /usr/local/include/vtk- and /usr/local/lib/vtk- on Linux .
Step 7: Link VTK in Your Projects
- Set environment variables or use CMake to locate VTK:
export VTK_DIR=/usr/local/lib/cmake/vtk-
- In Visual Studio, you can use the .vsprops file or Property Manager to include VTK binaries and headers .
- Ensure DLLs or shared libraries are in your system PATH for runtime linking.
Optional: Integration with Qt or Python
- For Qt applications, enable VTK_Group_Qt in CMake.
- For Python scripting, ensure Python development headers are available and the correct Python version is selected in CMake . Following these steps will provide a fully functional VTK installation ready for development and deployment.