VS2012编译安装VTK-5.10.1(支持Python)

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 初步配置

    下载pythoncmake并分别完成安装。打开cmake,设定"Where is the source code"和“Where to build the binaries”如下图所示:

图1

然后点击上图中的Configure按钮,弹出下面的窗体:

图2

    在上图中选择用于编译VTK的工具。由于本次用于编译VTK的是VS2012,因此选择"Visual Studio 11"。点击“Finish”按钮,则开始配置。

4 进一步配置

    完成第三步后,结果如下图所示。

图3

    勾选上图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”按钮继续配置。

这时将会提示错误,如下图:

图4

    搜索VTK_USE_TK(方法同图3),去掉勾选,继续“Configure”。这是提示错误如下图:

图5

    搜索PYTHON_INCLUDE_DIR,然后指定其路径为C:/Python25/include(实际值根据python的头文件路径进行修改)。然后继续“Configure“。此时,提示错误如下:

图6

    搜索PYTHON_LIBRARY,然后指定其值为:C:/Python25/libs/python25.lib(是一个库,而不是一个路径),如下图:

图7

    继续”Configure“,提示”Configuring done“则表示配置成功。然而还是有很多警告信息。

    搜索"PYTHON_EXECUTABLE",并且设定为“C:/Pyghon25”/python.exe(具体值根据python的实际安装路径来定),如下图所示:

图8

    继续“Configure”,将会提示如下:

图9

    这时候需要再次“Configure”。

    最后,搜素VTK_USE_MFC,并且勾选,继续“Configure”,等提示“Configuring done”后,点击“Generate”按钮,将产生VS2012的工程。

5 编译

    在D:/VTK/build目录中找到VTK.sln并且使用VS2012打开它。选中“All_BUILD”,右键单击,选择“生成”,如下图:

图10

    编译过程中出现的问题,见参考资料[4]。

6 安装

6.1 C++库和头文件安装    

    完成第5步的编译后,就可以进行安装。选中INSTALL,右键单击,选择“仅用于项目”,然后选择“仅生成INSTALL(B)”如下图:

图11

    完成后,在D:/VTK/install目录中将会安装好VTK的库和头文件。如下图:

图12
图12

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官网              

[3]VTK在VS2010中的安装(含python)和第一个例子

[4]VTK在VS2010下的安装方法

[5]VTK/Configure and Build

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

OneSea

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值