Getting started with vtk

Download vtk eBook


This section provides an overview of what vtk is, and why a developer might want to use it.

It should also mention any large subjects within vtk, and link out to the related topics. Since the Documentation for vtk is new, you may need to create initial versions of those related topics.

Installation or Setup

Building and Installation on Windows 7


  • If you want to build VTK from latest sources you need git from Here or you can download a snapshot of the code as a zip and unzip on to your disk drive
  • CMake
  • Microsoft Visual Studio 2015
  • Plenty of free space - atleast a couple of GB to be on the safe side, really depending on what all you want to build

Getting Ready

  • I like to keep things clean so I usually create 3 folders like so:
c:\vtk              #
c:\vtk\src          # 'code base' folder
c:\vtk\build        # 'out of source' build folder
c:\vtk\install      # 'install folder' where the 'installed' files will reside
  • If using the git method,

    • open a command prompt
    • change working directory cd c:\vtk\src
    • clone the git repository git clone . This could take a while depending on your internet connection speed
    • If you are working behind a proxy, you will need to setup git to use it. See this question on how to do that.
  • If using the zip method, unzip the source code into c:\vtk\src


  • Launch the CMake GUI
  • Select c:\vtk\src for Where is the source code:
  • Select c:\vtk\build for Where to build the binaries:
  • Hit Configure and select Visual Studio 2015 as the required generator
  • You will be presented with a number of configuration options
  • I generally use the following settings for a minimal build
    • CMAKE_INSTALL_PREFIX = c:\vtk\install
    • BUILD_SHARED_LIBS ticked
    • BUILD_TESTING unticked
    • CMAKE_CXX_MP_FLAG ticked. This will use all the CPU cores (on multicore/multiprocessor systems) to speed up the build
  • Keeping Hitting Configure correcting any errors until all the RED entries become WHITE
  • Hit Generate
  • Close CMake GUI


  • If the generation was successful there should be
    • A Visual Studio Solution :
    • A bunch of project files -
  • You can build this using either from a command line or using the IDE
  • I prefer the command line as it is generally faster and uses less RAM
  • Using the command line
    • Launch Developer Command Prompt For Visual Studio 2015
    • Change working directory: cd c:\vtk\build
    • Launch msbuild:
      • for debug builds
        • msbuild /p:Configuration=Debug ALL_BUILD.vcxproj
        • msbuild /p:Configuration=Debug INSTALL.vcxproj
      • for release builds
        • msbuild /p:Configuration=Release ALL_BUILD.vcxproj
        • msbuild /p:Configuration=Release INSTALL.vcxproj
  • Using the IDE
    • Open the VTK.sln with Visual Studio 2015 and build the INSTALL.vcxproj
    • This technique is usually slower as the IDE will start building intellisense for each of the projects listed in the solution
  • c:\vtk\install should now have some new folders
    • bin # contains the dll files
    • lib # contains the lib files
    • cmake
    • share
    • include # contains the header files

Using the build

  • To Use VTK in a Visual C++ project, one has to
    • Configure the compiler header file search path to include c:\vtk\include\vtk-<version>
    • Configure the linker library file search path to include c:\vtk\lib
    • Configure the linker to link to the required .lib files
    • Copy the required DLLs to output folder
  • I have put together a small props file to handle all the four tasks c:\vtk\vtk.vsprops
<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion="4.0" xmlns="">


    <Target Name="CopyVTKBinariesList">
            <VtkBinaries Include="$(VTK_BIN_DIR)\*.dll" />
        <Copy SourceFiles="@(VtkBinaries)"
              SkipUnchangedFiles="true" />

    <ItemGroup />

  • The above vsprops file copies all the available dlls in the c:\vtk\bin folder.

  • An alternative way to make sure the DLLs can be located is to use alter the PATH environment variable for the debugging session and put the VTK binaries path as the first directory to be searched when loading dependencies. The below fragment can be instead of the CopyVTKBinariesList task to do this.

  • For final deployment you might want to use a tool like Dependency Walker to track down which dlls and their dependencies are used and only bundle only those for redistribution.

  • To use the props file in a Visual C++ project you can either use the Property Manager tool within Visual Studio (Menu: View => Property Manager) or edit the vcxproj using a text editor and add this following line <Import Project="C:\vtk\vtk.vsprops" /> below the other project imports.

Cleaning Up

  • If you like to recover some disk space, you can delete the c:\vtk\build folder but the downside is you cannot debug into vtk


  • Simply delete the c:\vtk folder if you dont want to VTK anymore

MacOSX and Unix:

  1. Install the latest version of CMake available here
  2. Download the latest VTK here.
  3. Create a build directory for VTK mkdir <path_to_build_directory
  4. Configure with ccmake <path_to_VTK_directory -G "UNIX Makefiles" \ -DVTK_USE_QVTK:BOOL=ON \ -DVTK_USE_CARBON:BOOL=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DVTK_USE_GUISUPPORT:BOOL=ON or use the GUI to do so with ccmake <path_to_VTK_directory
  5. Get into the build directory and use make -j (you don't have to use -j but compilation is really long.
  6. Finally use make install


75 Contributors: 3
Monday, September 12, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial:

Download eBook