VTK入门教程05.01:Windows下编译

系列索引:VTK入门教程索引

VTK官网提供了源码、数据包、Python包,但是没有C++相关库,所以需要自己编译。

源码

下载源码(2024.04.15)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
PS D:\Code> git clone --recursive https://gitlab.kitware.com/vtk/vtk
Cloning into 'vtk'...
warning: redirecting to https://gitlab.kitware.com/vtk/vtk.git/
remote: Enumerating objects: 710989, done.
remote: Counting objects: 100% (2068/2068), done.
remote: Compressing objects: 100% (889/889), done.
remote: Total 710989 (delta 1233), reused 1861 (delta 1166), pack-reused 708921
Receiving objects: 100% (710989/710989), 259.97 MiB | 825.00 KiB/s, done.
Resolving deltas: 100% (547710/547710), done.
Updating files: 100% (21933/21933), done.
Submodule 'VTK-m' (https://gitlab.kitware.com/vtk/vtk-m.git) registered for path 'ThirdParty/vtkm/vtkvtkm/vtk-m'
Cloning into 'D:/Code/vtk/ThirdParty/vtkm/vtkvtkm/vtk-m'...
remote: Enumerating objects: 96066, done.
remote: Counting objects: 100% (2162/2162), done.
remote: Compressing objects: 100% (923/923), done.
remote: Total 96066 (delta 1230), reused 2094 (delta 1201), pack-reused 93904
Receiving objects: 100% (96066/96066), 24.77 MiB | 972.00 KiB/s, done.
Resolving deltas: 100% (78032/78032), done.
Submodule path 'ThirdParty/vtkm/vtkvtkm/vtk-m': checked out '3c9249871a5458cac01bbfe83307232aadd6bed5'

配置

源码没有太多依赖,直接使用CMake打开配置

1
2
3
4
CMAKE_INSTALL_PREFIX
BUILD_SHARED_LIBS
VTK_LEGACY_REMOVE
qt相关,注意Qt版本和位数

生成VS工程,并使用VS编译

Release版耗时37分钟,134MB

Debug版耗时25分钟,415MB

错误

FiltersReduction重定义

编译提示此模块和VTKCore模块有重定义,进入Common/Core/vtkConstantImplicitBackend.h

1
struct VTKCOMMONCORE_EXPORT vtkConstantImplicitBackend final

改成

1
struct vtkConstantImplicitBackend final

资源

CSDN:VTK 9.3.0 VS2019+Qt5.15.2自编译Debug+Release版


VTK入门教程05.01:Windows下编译
https://blog.jackeylea.com/vtk/how-to-build-vtk-under-windows/
作者
JackeyLea
发布于
2024年4月16日
许可协议