VTK下载地址:https://vtk.org/download/
cmake下载地址:https://cmake.org/download/
版本对应方面,如果你的项目对版本没有要求,就不用在意。我就是自己随机搭建的,VTK选择最新版本吧,如果后面其他的库不支持高版本 ,我在更好低版本的。这里只是介绍一下编译过程。
这个最新版本9.3.0。
下载8.2.0版本
选择Source下的.zip版本,tar.gz是Linux的。cmake记得下载. msi后缀的,这里选择64位的即win64,下载好后直接双击默认下一步安装即可。这里我们要自己编译,所以下载 VTK-8.2.0.zip这个文件。
安装好Cmake
如果选择 Qt的gcc和g++编译器,可以参考我的博客
Cmake:Error in configuration process,project files may be invalid.Qt编译opencv的经验之谈。_Vertira的博客-CSDN博客
编译VTK和 编译opencv 差别不大。
如果出现这种错误看我的连接
error: ‘std::_hypot‘ has not been declared using std::hypot;_Vertira的博客-CSDN博客
如果没有错误,就忽略上面的连接
第一次Configure应该要挺长时间,5-10分钟吧,具体看电脑的处理器性能,这只是第一次,后面还有好几次,因为需要继续改参数配置,第一次的Configure过后,会出现下图所示的一片红色,这个不用担心,这里需要修改的地方有三处,分别是:
- BUILD_EXAMPLES:生成一些vtk官方的examples,帮助理解学习,当然不选择也没事;
- CMAKE_INSTALL_PREFIX:这里存放之后使用vtk时的一些动态库dll,二进制库lib,vtk的一些头文件之类的。图上此项的位置已经修改为 刚创建的那个vtk-pefix文件夹的路径(也可以把文件夹的路径名称改为vtk-install);
- VTK_Group_Qt:我这里需要在Qt中使用vtk,所以选择了此项。
编译出错:::::?????????
CMake Error at GUISupport/Qt/CMakeLists.txt:71 (find_package):By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project hasasked CMake to find a package configuration file provided by "Qt5", butCMake did not find one.Could not find a package configuration file provided by "Qt5" with any ofthe following names:Qt5Config.cmakeqt5-config.cmakeAdd the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"to a directory containing one of the above files. If "Qt5" provides aseparate development package or SDK, be sure it has been installed.
CMake Error at GUISupport/Qt/CMakeLists.txt:71 (find_package):
By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
这个错误网上查了一下,原来是一些文件的路径没有设置
那就在cmake界面的add Entry,把上面的路径一点一点的添加上去。
结果出现这样的问题,
CMake Warning (dev) at E:/Qt5/VTK/build/CMakeTmp/VTK_UNDEFINED_SYMBOLS_ALLOWED/CMakeLists.txt:2 (project):cmake_minimum_required() should be called prior to this top-level project()call. Please see the cmake-commands(7) manual for usage documentation ofboth commands.
This warning is for project developers. Use -Wno-dev to suppress it.Performing Test VTK_UNDEFINED_SYMBOLS_ALLOWED - Failed
Group StandAlone modules: vtkChartsCore;vtkCommonComputationalGeometry;vtkCommonCore;vtkCommonDataModel;vtkCommonExecutionModel;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkDomainsChemistry;vtkFiltersAMR;vtkFiltersCore;vtkFiltersExtraction;vtkFiltersFlowPaths;vtkFiltersGeneral;vtkFiltersGeneric;vtkFiltersGeometry;vtkFiltersHybrid;vtkFiltersHyperTree;vtkFiltersImaging;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelImaging;vtkFiltersPoints;vtkFiltersProgrammable;vtkFiltersSMP;vtkFiltersSelection;vtkFiltersSources;vtkFiltersStatistics;vtkFiltersTexture;vtkFiltersTopology;vtkFiltersVerdict;vtkIOAMR;vtkIOAsynchronous;vtkIOCityGML;vtkIOCore;vtkIOEnSight;vtkIOExodus;vtkIOGeometry;vtkIOImage;vtkIOImport;vtkIOInfovis;vtkIOLSDyna;vtkIOLegacy;vtkIOMINC;vtkIOMovie;vtkIONetCDF;vtkIOPLY;vtkIOParallel;vtkIOParallelXML;vtkIOSQL;vtkIOSegY;vtkIOTecplotTable;vtkIOVeraOut;vtkIOVideo;vtkIOXML;vtkIOXMLParser;vtkImagingColor;vtkImagingCore;vtkImagingFourier;vtkImagingGeneral;vtkImagingHybrid;vtkImagingMath;vtkImagingMorphological;vtkImagingSources;vtkImagingStatistics;vtkImagingStencil;vtkInfovisCore;vtkInfovisLayout;vtkParallelCore
Group MPI modules: vtkDomainsParallelChemistry;vtkFiltersParallelGeometry;vtkFiltersParallelMPI;vtkFiltersParallelVerdict;vtkIOMPIImage;vtkIOMPIParallel;vtkIOParallelNetCDF;vtkParallelMPI
Group Imaging modules: vtkFiltersImaging;vtkImagingColor;vtkImagingFourier;vtkImagingGeneral;vtkImagingHybrid;vtkImagingMath;vtkImagingMorphological;vtkImagingSources;vtkImagingStatistics;vtkImagingStencil;vtkInteractionImage;vtkRenderingImage
Group Qt modules: vtkGUISupportQt;vtkGUISupportQtSQL;vtkRenderingQt;vtkViewsQt
Group Rendering modules: vtkGeovisCore;vtkIOExport;vtkIOExportPDF;vtkInteractionImage;vtkInteractionStyle;vtkInteractionWidgets;vtkRenderingAnnotation;vtkRenderingContext2D;vtkRenderingCore;vtkRenderingFreeType;vtkRenderingImage;vtkRenderingLOD;vtkRenderingLabel;vtkRenderingVolume;vtkViewsContext2D;vtkViewsCore;vtkViewsInfovis
Group Tk modules: vtkRenderingTk
Group Views modules: vtkViewsContext2D;vtkViewsGeovis
Group Web modules: vtkWebCore;vtkWebPython;vtkWebGLExporter
Backend OpenGL2 modules: vtkDomainsChemistryOpenGL2;vtkIOExportOpenGL2;vtkImagingOpenGL2;vtkRenderingContextOpenGL2;vtkRenderingGL2PSOpenGL2;vtkRenderingLICOpenGL2;vtkRenderingOpenGL2;vtkRenderingOpenVR;vtkRenderingVolumeOpenGL2
Enabling modules for OpenGL2.
CMake Deprecation Warning at Utilities/KWIML/vtkkwiml/CMakeLists.txt:20 (cmake_minimum_required):Compatibility with CMake < 3.5 will be removed from a future version ofCMake.Update the VERSION argument <min> value or use a ...<max> suffix to tellCMake that the project does not need compatibility with older versions.CMake Deprecation Warning at Utilities/KWSys/vtksys/CMakeLists.txt:84 (CMAKE_MINIMUM_REQUIRED):Compatibility with CMake < 3.5 will be removed from a future version ofCMake.Update the VERSION argument <min> value or use a ...<max> suffix to tellCMake that the project does not need compatibility with older versions.CMake Deprecation Warning at ThirdParty/doubleconversion/vtkdoubleconversion/CMakeLists.txt:1 (cmake_minimum_required):Compatibility with CMake < 3.5 will be removed from a future version ofCMake.Update the VERSION argument <min> value or use a ...<max> suffix to tellCMake that the project does not need compatibility with older versions.CMake Deprecation Warning at ThirdParty/verdict/vtkverdict/CMakeLists.txt:2 (cmake_minimum_required):Compatibility with CMake < 3.5 will be removed from a future version ofCMake.Update the VERSION argument <min> value or use a ...<max> suffix to tellCMake that the project does not need compatibility with older versions.CMake Warning (dev) at E:/Qt5/VTK/build/Examples/Build/vtkLocal/CMakeTmp/VTK_UNDEFINED_SYMBOLS_ALLOWED/CMakeLists.txt:2 (project):cmake_minimum_required() should be called prior to this top-level project()call. Please see the cmake-commands(7) manual for usage documentation ofboth commands.
This warning is for project developers. Use -Wno-dev to suppress it.Performing Test VTK_UNDEFINED_SYMBOLS_ALLOWED - Failed
Configuring done (51.0s)
Performing Test VTK_UNDEFINED_SYMBOLS_ALLOWED - Failed
没有报错,但是执行失败????????? 这是什么原因呢?
我的电脑是比较老旧,显卡也是英伟达GF 525M,虽然比较老,应该不至于吧。
重新删除重新编译。试一试