VTK下載地址:https://vtk.org/download/
cmake下載地址:https://cmake.org/download/
版本對(duì)應(yīng)方面,如果你的項(xiàng)目對(duì)版本沒有要求,就不用在意。我就是自己隨機(jī)搭建的,VTK選擇最新版本吧,如果后面其他的庫不支持高版本 ,我在更好低版本的。這里只是介紹一下編譯過程。
?這個(gè)最新版本9.3.0。
下載8.2.0版本
選擇Source下的.zip版本,tar.gz是Linux的。cmake記得下載.? ? ?msi后綴的,這里選擇64位的即win64,下載好后直接雙擊默認(rèn)下一步安裝即可。這里我們要自己編譯,所以下載? VTK-8.2.0.zip這個(gè)文件。
安裝好Cmake
如果選擇 Qt的gcc和g++編譯器,可以參考我的博客
Cmake:Error in configuration process,project files may be invalid.Qt編譯opencv的經(jīng)驗(yàn)之談。_Vertira的博客-CSDN博客
編譯VTK和 編譯opencv 差別不大。
如果出現(xiàn)這種錯(cuò)誤看我的連接
error: ‘std::_hypot‘ has not been declared using std::hypot;_Vertira的博客-CSDN博客
?如果沒有錯(cuò)誤,就忽略上面的連接
?
第一次Configure應(yīng)該要挺長時(shí)間,5-10分鐘吧,具體看電腦的處理器性能,這只是第一次,后面還有好幾次,因?yàn)樾枰^續(xù)改參數(shù)配置,第一次的Configure過后,會(huì)出現(xiàn)下圖所示的一片紅色,這個(gè)不用擔(dān)心,這里需要修改的地方有三處,分別是:
- BUILD_EXAMPLES:生成一些vtk官方的examples,幫助理解學(xué)習(xí),當(dāng)然不選擇也沒事;
- CMAKE_INSTALL_PREFIX:這里存放之后使用vtk時(shí)的一些動(dòng)態(tài)庫dll,二進(jìn)制庫lib,vtk的一些頭文件之類的。圖上此項(xiàng)的位置已經(jīng)修改為 剛創(chuàng)建的那個(gè)vtk-pefix文件夾的路徑(也可以把文件夾的路徑名稱改為vtk-install);
- VTK_Group_Qt:我這里需要在Qt中使用vtk,所以選擇了此項(xiàng)。
?編譯出錯(cuò):::::??????????
?
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 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.
?
這個(gè)錯(cuò)誤網(wǎng)上查了一下,原來是一些文件的路徑?jīng)]有設(shè)置
那就在cmake界面的add Entry,把上面的路徑一點(diǎn)一點(diǎn)的添加上去。
?
?
?結(jié)果出現(xiàn)這樣的問題,
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 of
both 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 of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake 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 of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake 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 of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake 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 of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake 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 of
both 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
沒有報(bào)錯(cuò),但是執(zhí)行失敗?????????? 這是什么原因呢?
我的電腦是比較老舊,顯卡也是英偉達(dá)GF 525M,雖然比較老,應(yīng)該不至于吧。文章來源:http://www.zghlxwxcb.cn/news/detail-692861.html
重新刪除重新編譯。試一試文章來源地址http://www.zghlxwxcb.cn/news/detail-692861.html
到了這里,關(guān)于Qt +VTK+Cmake 編譯和環(huán)境配置(第一篇 采坑)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!