VTK/Configure and Build

From KitwarePublic
Jump to navigationJump to search

Introduction

Hello! Welcome to the wiki.

This page is applicable for VTK 6.0 and above. For earlier versions, refer to a deprecated version of this document.

This page describes how to configure and build VTK, with several popular options turned on.

Prerequisites

  • The VTK build process requires CMake version 2.8.8 or higher and a working compiler. On Unix-like operating systems, it also requires Make, while on Windows it requires Visual Studio (8 or later).
  • Building VTK with Qt is a common use case for the creation of nice user interfaces. Using Qt 4.8.* is recommended, but earlier versions and Qt 5.* are in various stages of support. Visit the Qt download page to get a copy of the source code or installer. Either the LGPL or commercial versions of Qt may be used.

Download And Install CMake

CMake is a tool that makes cross-platform building simple. If CMake does not exist on the system, and there are no pre-compiled binaries, use the instructions below on how to build it. Use the most recent source or binary version of CMake from the CMake web site.

Using Binaries

There are several precompiled binaries available at the CMake download page.

On Unix-like operating systems

Let's say on Linux, download the appropriate version and follow these instructions:

cd $HOME
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Linux-i386.tar.gz
mkdir software
cd software
tar xvfz ../cmake-2.8.12.2-Linux-i386.tar.gz
  • Now you have the directory $HOME/software/cmake-2.8.8-Linux-i386/bin, and inside there are executables cmake and ccmake.
  • You can also install CMake in the /usr/local or /opt by untaring and copying sub-directories. The rest of the instructions will assume the executables are in your $PATH.

On Windows

On Windows, if you are not administrator

Build Your Own CMake

On Unix-like operating systems

Download the source code: http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

cd $HOME
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tar xzf cmake-2.8.12.2.tar.gz
cd cmake-2.8.12.2
./configure --prefix=$HOME/software
make
make install
  • Again, you can install it in /usr/local or /opt by changing the prefix.

On Windows

To build CMake on windows, a previous version of CMake is required. This can be downloaded from the Cmake download page: [1].

Download VTK Source code

Download a Release

Download a VTK release from the VTK Downloads page.

Checkout the VTK Repository with Git

If you want the nightly updates of VTK, this is your best bet. Checking out from source control also greatly facilitates the process of contributing back. Note that you may need to download and install a git client, here: [2]

Tip: Check out the VTK Git landing page.

On Unix-like operating systems

Prepare directory for download
 # mkdir $HOME/projects
 # cd $HOME/projects

To download the source code 
 # git clone git://vtk.org/VTK.git
 # cd VTK
 
To update the code
 # git fetch origin
 # git rebase origin/master

On Windows

We recommend msysgit. msysgit provides an msys shell that has the appropriate environment set up for using git and its tools.

Configure VTK with CMake

  • Always use a separate build directory. Do not build in the source directory.

On Unix-like systems

  • Use ccmake (Curses CMake GUI) from the CMake installed location. CCMake is a Curses based GUI for CMake. To run it go to the build directory and specify the VTK source directory as an argument.
mkdir $HOME/projects/VTK-build
cd $HOME/projects/VTK-build

ccmake $HOME/projects/VTK

Vtk-ccmake.png

About CCMake (Curses CMake GUI)

  • Iterative process.
    • Select values, run configure (c key).
    • Set the settings, run configure, set the settings, run configure, etc.
  • Repeat until all values are set and the generate option is available (g key).
  • Some variables (advanced variables) are not visible right away.
  • To see advanced varables, toggle to advanced mode (t key).
  • To set a variable, move the cursor to the variable and press enter.
    • If it is a boolean (ON/OFF) it will flip the value.
    • If it is string or file, it will allow editing of the string.
    • For file and directories, the <tab> key can be used to complete.
  • To search for a variable press '/' key; to repeat the search, press the 'n' key.

On Windows

  • Use CMakeSetup from the CMake install location.
  • Make sure to select the appropriate source and the build directory.
  • Also, make sure to pick the appropriate generator. Some CMake versions will ask you to select the generator the first time you press Configure instead of having a drop-down menu in the main dialog.

Vtk-cmake-gui.png

About CMake GUI

  • Iterative process.
    • Select values, press the Configure button.
    • Set the settings, run configure, set the settings, run configure, etc.
  • Repeat until all values are set and the OK button becomes available.
  • Some variables (advanced variables) are not visible right away.
  • To see advanced varables, toggle to advanced mode ("Show Advanced Values" toggle).
  • To set the value of a variable, click on that value.
    • If it is boolean (ON/OFF), a drop-down menu will appear for changing the value.
    • If it is file or directory, an ellipsis button will appear ("...") on the far right of the entry. Clicking this button will bring up the file or directory selection dialog.
    • If it is a string, it will become an editable string.