Download VTK 6.3.0
Download Qt 5.4 with MinGW 4.9.1
Download CMake 3.2.0
I assume you‘ve already installed Qt 5.4 with MinGW 4.9.1 and CMake 3.2.0 correctly.
Pre-process the VTK:
Open CMakeLists.txt in your extracted VTK-6.3.0 folder, find set(VTK_USE_WIN32_THREADS 1), change it to: set(VTK_USE_PTHREADS 1)
mark_as_advanced(VTK_THREAD_MODEL) if(CMAKE_USE_WIN32_THREADS_INIT) set(VTK_USE_PTHREADS 1) set(CMAKE_THREAD_LIBS_INIT "") elseif(CMAKE_USE_PTHREADS_INIT) set(VTK_USE_PTHREADS 1) if(CMAKE_HP_PTHREADS_INIT) set(VTK_HP_PTHREADS 1) endif() elseif(CMAKE_USE_SPROC_INIT) set(VTK_USE_SPROC 1) endif() set(CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING "Thread library used.")
Open C:\VTK6.3.0\VTK-6.3.0\ThirdParty\libxml2\vtklibxml2\threads.c , add #undef HAVE_WIN32_THREADS after #include "libxml.h"
#define IN_LIBXML #include "libxml.h" #undef HAVE_WIN32_THREADS #include <string.h>
Compile the VTK:
Start CMake 3.2.0, fill the source and destination:
Click Configure and use MinGW Makefiles to complie.
When first configure is done, select Grouped and Advanced.
Go to CMAKE->CMAKE_INSTALL_PREFIX, change the value to C:\VTK6.3.0\MinGW
Go to Module, select Module_vtkGUISupportQt、Module_vtkGUISupportQtOpenGL、Module_vtkGUISupportQtSQL、Module_vtkGUISupportQtWebkit、Module_vtkRenderingQt、Module_vtkViewsQt
Go to VTK, select VTK_Group_Qt
Go CMake->CMAKE_BUILD_TYPE, change value to Release
Click Add Entry, add QT_QMAKE_EXECUTABLE as Name, PATH as Type, C:/Qt/5.4/mingw491_32/bin/qmake.exe as value:
Click Add Entry, add CMAKE_PREFIX_PATH as Name, PATH as Type, C:/Qt/5.4/mingw491_32 as value:
Click Configure again, and you gonna get an error said: "Error in configuration processs, project files may be invalid."
Go to Ungrouped Entries->QT_VTK_VERSION, change value to 5, then click Configure again.
After configure is done, click Generate.
Go back to your build folder, open command line, type: mingw32-make
Wait a long time for make process, have a cup of coffee.
After make is done, type mingw32-make install
Now, the configuration is done, enjoy it :)
Use the VTK:
Reference:
http://zhangxc.com/2015/02/qt5-mingw-cmake-vtk6
VTK 6.3.0 Qt 5.4 MinGW 4.9.1 Configuration 配置
原文:http://www.cnblogs.com/grandyang/p/4884184.html