|Installation of VTK 6 in Ubuntu
Download VTK 6 source from download site into a local directory and unzip it. Suppose the unzipped source directory is /home/me/Downloads/VTK-6.2.0.
Create a separate build directory, eg., /opt/VTK-build.:
In ccmake, type "c" to configure. Then, select the options you like, e.g., turning on
You can also change the install prefix, which defaults to /usr/local.
Type "c" one or more times until no errors occur. If you need to install doxygen, do
sudo apt-get install doxygen
Then, type "g" to generate.
Then, create a release directory, e.g., /opt/VTK-6.2, and, generate the Makefile:
cmake -DCMAKE_BUILD_TYPE:STRING=Release /home/me/Downloads/VTK-6.2.0
To use VTK 6 with Qt 5, do
cmake -DVTK_QT_VERSION:STRING=5 \
By default, the .h files are installed in /usr/local/include/vtk-6.2 and the library files are installed in /usr/local/lib. To be consistent, you can create a directory /usr/local/lib/vtk-6.2 and move the library files into this directory.
The libraries are named as libvtk*-6.2.so.1. This naming convention is inconvenient to use. A more convenient naming convetion is simply libvtk*.so. To generate symbolic links of the convenient names to the library files, download this script and run it in the folder that contains the library files.
|Migration of VTK 5 to VTK 6
If your VTK 6.2 code is not compiled with cmake, it may get the error "no override found for ..." and a NULL pointer when it calls New() function of a module. This is because the factory methods of VTK 6 require explicit initialisation. To resolve this problem, add the following at the top of main.cpp, the file that contains main():
This will initialise vtkRenderingOpenGL object factories.
If you are using VTK 6.0 or 6.1, then inlcude the following before including any VTK header files:
#define vtkRenderingCore_AUTOINIT \
#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL)
VTK 6 also requires explicit linking of additional libraries that are not necessary in VTK 5 such as libvtkCommonColor.so, libvtkCommonSystem.so, etc.
To identify the library file that contains a class, e.g., vtkActor, search vtkActor.h in the VTK source folders. The name of the folder that contains vtkActor.h is the name of the library, in this case, .../Rendering/Core, which corresponds to libvtkRenderingCore.so.
To identify the library file that contains a class function, e.g., vtkColorTransferFunction, download this script file, save it, e.g., as findlib and change its mode to executable:
chmod +x findlib
Then, run the script file as follows:
findlib <path of library folder> <function name>
For more information, refer to VTK 6 Migration Guide.
|Installation of VTK 5 in Ubuntu
| To use VTK 5 together with Qt 4, do
sudo apt-get install libvtk5-qt4-dev
|Compiling VTK Programs
|To compile VTK with Qt, refer to Compiling Qt and VTK. This method can also be used to compile VTK programs without Qt.
Another way to compile VTK program by itself is as follows. Go to the directory that contains the program, create the file CMakeLists.txt. This file contains information that tells cmake how to generate the required make file. For example,
In this example, the name of the source file is test1.cpp and the names of the project and the executable are test1.
After creating CMakeLists.txt, compile the program as follows:
The first command invokes cmake to create the makefile which make uses to compile the program.
For more information about cmake, refer to Kitware's online page.
|For online documentation, browse VTK online documentation.
For offline documentation, download the html documentation from VTK website. Note that this documentation contains many, many files.