1 源码下载
到参考资料[1]下载vtk-5.10.1.zip和vtkdata-5.10.1.zip。
2 源码解压
这里以D:盘为例进行说明。在D:盘中创建一个目录VTK,然后在其中创建4个目录:source,、build、data和install。将vtk-5.10.1.zip和vtkdata-5.10.1.zip分别解压到VTK/src目录和VTK/data目录中。
3 初步配置
下载python和cmake并分别完成安装。打开cmake,设定"Where is the source code"和“Where to build the binaries”如下图所示:
![](https://i-blog.csdnimg.cn/blog_migrate/c79e1e6ddea021955c7506e5fcaeda2f.png)
然后点击上图中的Configure按钮,弹出下面的窗体:
![](https://i-blog.csdnimg.cn/blog_migrate/223270c5a47b9bf8dbce2e7a2858cb33.png)
在上图中选择用于编译VTK的工具。由于本次用于编译VTK的是VS2012,因此选择"Visual Studio 11"。点击“Finish”按钮,则开始配置。
4 进一步配置
完成第三步后,结果如下图所示。
![](https://i-blog.csdnimg.cn/blog_migrate/7da32409c35c107e080dabc838fdef19.png)
勾选上图advance选项,并且在Search输入框中搜索出BUILD_EXAMPLES、BUILD_TESTING、BUILD_SHARED_LIBS、VTK_USE_GUISUPPORT和VTK_WRAP_PYTHON(关于python,见参考资料[3]),然后勾选上。并且分别指定CMAKE_INSTALL_PREFIX和VTK_DATA_ROOT为D:/VTK/install和D:/VTK/data。完成后再次点击“Configure”按钮继续配置。
这时将会提示错误,如下图:
![](https://i-blog.csdnimg.cn/blog_migrate/5e7bbbd0bfe839404b5f78fa1dca093f.png)
搜索VTK_USE_TK(方法同图3),去掉勾选,继续“Configure”。这是提示错误如下图:
![](https://i-blog.csdnimg.cn/blog_migrate/31f28d401d2efb6075566aa6262a6b46.png)
搜索PYTHON_INCLUDE_DIR,然后指定其路径为C:/Python25/include(实际值根据python的头文件路径进行修改)。然后继续“Configure“。此时,提示错误如下:
![](https://i-blog.csdnimg.cn/blog_migrate/a24776287653173bd2fdf85e5a365011.png)
搜索PYTHON_LIBRARY,然后指定其值为:C:/Python25/libs/python25.lib(是一个库,而不是一个路径),如下图:
![](https://i-blog.csdnimg.cn/blog_migrate/782faa4472706e58e37abaa7d0b466b8.png)
继续”Configure“,提示”Configuring done“则表示配置成功。然而还是有很多警告信息。
搜索"PYTHON_EXECUTABLE",并且设定为“C:/Pyghon25”/python.exe(具体值根据python的实际安装路径来定),如下图所示:
![](https://i-blog.csdnimg.cn/blog_migrate/40cd891de1d86dc05d32500a94cefdde.png)
继续“Configure”,将会提示如下:
![](https://i-blog.csdnimg.cn/blog_migrate/03f6d3b7a33a5ab600066ada189172a2.png)
这时候需要再次“Configure”。
最后,搜素VTK_USE_MFC,并且勾选,继续“Configure”,等提示“Configuring done”后,点击“Generate”按钮,将产生VS2012的工程。
5 编译
在D:/VTK/build目录中找到VTK.sln并且使用VS2012打开它。选中“All_BUILD”,右键单击,选择“生成”,如下图:
![](https://i-blog.csdnimg.cn/blog_migrate/a28abbfac187afe3acf05a200eba39cd.png)
编译过程中出现的问题,见参考资料[4]。
6 安装
6.1 C++库和头文件安装
完成第5步的编译后,就可以进行安装。选中INSTALL,右键单击,选择“仅用于项目”,然后选择“仅生成INSTALL(B)”如下图:
![](https://i-blog.csdnimg.cn/blog_migrate/3f28f4b559d71722e192e6735b016401.png)
完成后,在D:/VTK/install目录中将会安装好VTK的库和头文件。如下图:
![图12](https://i-blog.csdnimg.cn/blog_migrate/0642c5d6d7242c5cf2f8be0e6c2ac837.png)
6.2 Python安装
编译好后,进入目录E:\VTK\vtk-5.10.1\bin\Wrapping\Python(具体目录,根据实际编译的情况进行修改),必须进这个目录,否则在执行下面的命令式将会提示找不到vtk目录。
在CMD中执行下面命令:(前提是已经在Windows中安装了python)
python setup.py install BUILD_TYPE=Debug
安装过程提示信息如下:
E:\VTK\vtk-5.10.1\bin\Wrapping\Python>python setup.py install BUILD_TYPE=Debug
running install
running build
running build_py
running install_lib
creating C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\charts.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\chemistry.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\common.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\filtering.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\genericfiltering.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\geovis.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\graphics.py -> C:\Python25\Lib\site-packages\vtk
creating C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\gtk\GtkGLExtVTKRenderWindow.py -> C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\gtk\GtkGLExtVTKRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\gtk\GtkVTKRenderWindow.py -> C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\gtk\GtkVTKRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\gtk\__init__.py -> C:\Python25\Lib\site-packages\vtk\gtk
copying build\lib\vtk\hybrid.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\imaging.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\infovis.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\io.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\parallel.py -> C:\Python25\Lib\site-packages\vtk
creating C:\Python25\Lib\site-packages\vtk\qt
copying build\lib\vtk\qt\QVTKRenderWidget.py -> C:\Python25\Lib\site-packages\vtk\qt
copying build\lib\vtk\qt\QVTKRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\qt
copying build\lib\vtk\qt\__init__.py -> C:\Python25\Lib\site-packages\vtk\qt
creating C:\Python25\Lib\site-packages\vtk\qt4
copying build\lib\vtk\qt4\QVTKRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\qt4
copying build\lib\vtk\qt4\__init__.py -> C:\Python25\Lib\site-packages\vtk\qt4
copying build\lib\vtk\qvtk.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\rendering.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\required.py -> C:\Python25\Lib\site-packages\vtk
creating C:\Python25\Lib\site-packages\vtk\test
copying build\lib\vtk\test\BlackBox.py -> C:\Python25\Lib\site-packages\vtk\test
copying build\lib\vtk\test\Testing.py -> C:\Python25\Lib\site-packages\vtk\test
copying build\lib\vtk\test\__init__.py -> C:\Python25\Lib\site-packages\vtk\test
copying build\lib\vtk\textanalysis.py -> C:\Python25\Lib\site-packages\vtk
creating C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\vtkLoadPythonTkWidgets.py -> C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\vtkTkImageViewerWidget.py -> C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\vtkTkPhotoImage.py -> C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\vtkTkRenderWidget.py -> C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\vtkTkRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\tk
copying build\lib\vtk\tk\__init__.py -> C:\Python25\Lib\site-packages\vtk\tk
creating C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\colors.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\misc.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\numpy_support.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\vtkConstants.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\vtkImageExportToArray.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\vtkImageImportFromArray.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\vtkMethodParser.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\vtkVariant.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\util\__init__.py -> C:\Python25\Lib\site-packages\vtk\util
copying build\lib\vtk\views.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\volumerendering.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\widgets.py -> C:\Python25\Lib\site-packages\vtk
creating C:\Python25\Lib\site-packages\vtk\wx
copying build\lib\vtk\wx\wxVTKRenderWindow.py -> C:\Python25\Lib\site-packages\vtk\wx
copying build\lib\vtk\wx\wxVTKRenderWindowInteractor.py -> C:\Python25\Lib\site-packages\vtk\wx
copying build\lib\vtk\wx\__init__.py -> C:\Python25\Lib\site-packages\vtk\wx
copying build\lib\vtk\__helper.py -> C:\Python25\Lib\site-packages\vtk
copying build\lib\vtk\__init__.py -> C:\Python25\Lib\site-packages\vtk
byte-compiling C:\Python25\Lib\site-packages\vtk\charts.py to charts.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\chemistry.py to chemistry.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\common.py to common.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\filtering.py to filtering.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\genericfiltering.py to genericf
iltering.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\geovis.py to geovis.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\graphics.py to graphics.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\gtk\GtkGLExtVTKRenderWindow.py to GtkGLExtVTKRenderWindow.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\gtk\GtkGLExtVTKRenderWindowInteractor.py to GtkGLExtVTKRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\gtk\GtkVTKRenderWindow.py to GtkVTKRenderWindow.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\gtk\GtkVTKRenderWindowInteractor.py to GtkVTKRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\gtk\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\hybrid.py to hybrid.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\imaging.py to imaging.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\infovis.py to infovis.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\io.py to io.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\parallel.py to parallel.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qt\QVTKRenderWidget.py to QVTKRenderWidget.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qt\QVTKRenderWindowInteractor.py to QVTKRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qt\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qt4\QVTKRenderWindowInteractor.py to QVTKRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qt4\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\qvtk.py to qvtk.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\rendering.py to rendering.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\required.py to required.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\test\BlackBox.py to BlackBox.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\test\Testing.py to Testing.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\test\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\textanalysis.py to textanalysis.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\vtkLoadPythonTkWidgets.py to vtkLoadPythonTkWidgets.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\vtkTkImageViewerWidget.py to vtkTkImageViewerWidget.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\vtkTkPhotoImage.py to vtkTkPhotoImage.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\vtkTkRenderWidget.py to vtkTkRenderWidget.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\vtkTkRenderWindowInteractor.py to vtkTkRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\tk\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\colors.py to colors.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\misc.py to misc.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\numpy_support.py to numpy_support.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\vtkConstants.py to vtkConstants.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\vtkImageExportToArray.py to vtkImageExportToArray.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\vtkImageImportFromArray.py to vtkImageImportFromArray.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\vtkMethodParser.py to vtkMethodParser.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\vtkVariant.py to vtkVariant.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\util\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\views.py to views.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\volumerendering.py to volumerendering.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\widgets.py to widgets.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\wx\wxVTKRenderWindow.py to wxVTKRenderWindow.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\wx\wxVTKRenderWindowInteractor.py to wxVTKRenderWindowInteractor.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\wx\__init__.py to __init__.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\__helper.py to __helper.pyc
byte-compiling C:\Python25\Lib\site-packages\vtk\__init__.py to __init__.pyc
running install_data
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkCommonPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkFilteringPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkIOPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkGraphicsPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkGenericFilteringPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkImagingPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkRenderingPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkVolumeRenderingPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkHybridPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkWidgetsPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkParallelPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkChartsPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkGeovisPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkInfovisPython.pyd -> C:\Python25\Lib\site-packages\vtk
copying E:\VTK\vtk-5.10.1\bin\bin\Debug\vtkViewsPython.pyd -> C:\Python25\Lib\site-packages\vtk
running install_egg_info
Writing C:\Python25\Lib\site-packages\VTK-5.10.1-py2.5.egg-info
通过上述提示信息,我们可以了解其安装过程,其实就是将文件复制到指定目录的一个过程。
参考资料
[1]VTK官网
[2]cmake官网