Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Building
This page describes how to build and install VTK. It covers building for
development, on both Unix-type systems (Linux, HP-UX, Solaris, macOS), and
Windows. Note that Unix-like environments such as Cygwin and MinGW are not
officially supported. However, patches to fix problems with these platforms
will be considered for inclusion. It is recommended that users which require
VTK to work on these platforms to submit nightly testing results for them.
A full-featured build of VTK depends on several open source tools and libraries
such as Python, Qt, CGNS, HDF5, etc. Some of these are included in the VTK
source itself (e.g., HDF5), while others are expected to be present on the
machine on which VTK is being built (e.g., Python, Qt).
VTK supports all of the common generators supported by CMake. The Ninja,
Makefiles, and Visual Studio generators are the most well-tested however.
Note that VTK does not support in-source builds, so you must have a build tree
that is not the source tree.
## Obtaining the sources
There are two approaches:
::::{tab-set}
:::{tab-item} Release Download
1. Download the source release `VTK-X.Y.Z.tar.gz` from https://vtk.org/download/.
2. Create a folder for VTK.
3. Extract the contents of the VTK folder in the downloaded archive to the subfolder called `source`
:::
:::{tab-item} Git Clone
To obtain VTK's sources locally, clone the VTK repository using [Git][git].
[git]: https://git-scm.org
Open `Git Bash` on Windows or a terminal on Linux and macOS and
execute the following:
```sh
mkdir -p ~/vtk
git clone --recursive https://gitlab.kitware.com/vtk/vtk.git ~/vtk/source
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
:::
::::
To use the latest features being developed or to make changes and
contribute to VTK, download the source using **Git Clone**.
## Prerequisites
VTK only requires a few packages in order to build in general, however
specific features may require additional packages to be provided to VTK's
build configuration.
Required:
* [CMake][cmake]
- Version 3.12 or newer, however, the latest version is always recommended.
If the system package management utilities do not offer cmake or if the offered version is too old
Precompiled binaries available on [CMake's download page][cmake-download].
* Supported compiler
- GCC 4.8 or newer
- Clang 3.3 or newer
- Apple Clang 7.0 (from Xcode 7.2.1) or newer
- Microsoft Visual Studio 2015 or newer
- Intel 14.0 or newer
### Optional Additions
- **ffmpeg**
When the ability to write `.avi` files is desired, and writing these files is
not supported by the OS, VTK can use the ffmpeg library. This is generally
true for Unix-like operating systems. Source code for ffmpeg can be obtained
from [the website][ffmpeg].
- **MPI**
To run VTK in parallel, an [MPI][mpi] implementation is required. If an MPI
implementation that exploits special interconnect hardware is provided on your
system, we suggest using it for optimal performance. Otherwise, on Linux/Mac,
we suggest either [OpenMPI][openmpi] or [MPICH][mpich]. On Windows, [Microsoft
MPI][msmpi] is required.
- **Python**
In order to use scripting, [Python][python] is required. The minimum supported version is **3.4**.
The instructions are using the system Python. On Ubuntu/Debian the required package is
`python3-dev`. If you use a different Python
implementation or a virtual environment make sure the environment you use is
activated. On Ubuntu/Debian the required package for creating virtual environments is
`python3-venv`.
- **Qt5**
VTK uses Qt as its GUI library (if the relevant modules are enabled).
Precompiled binaries are available on [Qt's website][qt-download].
Note that on Windows, the compiler used for building VTK must match the
compiler version used to build Qt. Version **5.9** or newer is required.
- **OSMesa**
Off-screen Mesa can be used as a software-renderer for running VTK on a server
without hardware OpenGL acceleration. This is usually available in system
packages on Linux. For example, the `libosmesa6-dev` package on Debian and
Ubuntu. However, for older machines, building a newer version of Mesa is
likely necessary for bug fixes and support. Its source and build instructions
can be found on [its website][mesa].
[cmake]: https://cmake.org
[cmake-download]: https://cmake.org/download
[ffmpeg]: https://ffmpeg.org
[mpi]: https://www.mcs.anl.gov/research/projects/mpi
[mpich]: https://www.mpich.org
[msmpi]: https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi
[openmpi]: https://www.open-mpi.org
[python]: https://python.org
[qt-download]: https://download.qt.io/official_releases/qt
[mesa]: https://www.mesa3d.org
## Creating the Build Environment
::::{tab-set}
:::{tab-item} Windows
* Install CMake
* Install [Visual Studio Community Edition][visual-studio]
* During installation select the "desktop development with C++" workload.
* Use "x64 Native Tools Command Prompt" for the installed Visual Studio
version to configure with CMake and to build with ninja.
* Get [ninja][ninja]. Unzip the binary and put it in `PATH`. Note that newer
Visual Studio releases come with a version of `ninja` already and should
already exist in `PATH` within the command prompt.
[ninja]: https://ninja-build.org
[visual-studio]: https://visualstudio.microsoft.com/vs
:::
:::{tab-item} Linux (Ubuntu/Debian)
Install the following packages:
```bash
$ sudo apt install \
build-essential \
cmake \
cmake-curses-gui \
mesa-common-dev \
mesa-utils \
freeglut3-dev \
ninja-build
```
:::
:::{tab-item} macOS
* Install CMake
* Install XCode
* Ensure XCode command line tools are installed:
```bash
xcode-select --install
```
:::
::::
```{note}
`ninja` is a more efficient alternative to `Makefiles` or Visual Studio solution files. The
speed increase is the most noticeable when doing incremental build.
```
## Configure
In order to build, CMake requires two steps, configure and build. VTK itself
does not support what are known as in-source builds, so the first step is to
create a build directory.
::::{tab-set}
:::{tab-item} Windows (Ninja)
Open "x64 Native Tools Command Prompt" for the installed Visual Studio:
```sh
ccmake -GNinja -S %HOMEPATH%\vtk\source -B %HOMEPATH%\vtk\build
```
Note that CMake GUI must also be launched from the "Native Tools Command Prompt".
:::
:::{tab-item} Windows (Visual Studio)
Use CMake to generate a Visual Studio solution file (`.sln`).
1. Open CMake GUI, either by typing `cmake-gui` on the command prompt or from the start-menu.
2. Enter the source and build directories
3. Click `[Configure]`
4. You will now get a selection screen in which you can specify your "generator". Select the one you need.
5. We are now presented with a few options that can be turned on or off as desired.
6. Click `[Configure]` to apply the changes.
7. Click `[Generate]`. This will populate the "build" sub-folder.
8. Finally, click `[Open Project]` to open the generated solution in Visual Studio.
:::
:::{tab-item} Linux/macOS
```sh
mkdir -p ~/vtk/build
cd ~/vtk/build
ccmake -GNinja ../path/to/vtk/source
```
The parameter `-GNinja` may be skipped to use the default generator (e.g `Unix Makefiles`).
:::
::::
```{admonition} **Missing dependencies**
:class: warning
CMake may not find all dependencies automatically in all cases. The steps
needed to find any given package depends on the package itself.
For general assistance, please see the documentation for
[`find_package`'s search procedure][cmake-find_package-search] and
[the relevant Find module][cmake-modules-find] (as available).
[cmake-find_package-search]: https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure
[cmake-modules-find]: https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules
```
:::{hint}
Different features can be enabled/disabled by setting the [Build Settings](build_settings.md) during the configure stage.
:::
## Building
To build VTK:
::::{tab-set}
:::{tab-item} Windows (Ninja)
```sh
cmake --build %HOMEPATH%\vtk\build --config Release
```
:::
:::{tab-item} Windows (Visual Studio)
Open the generated solution file.
1. Set the configuration to "Release"
2. On the menu bar, choose `Build`, and then choose `Build Solution`.
:::
:::{tab-item} Linux/macOS
```sh
cmake --build ~/vtk/build
```
:::
::::