STEP ONE
- Download ITK, VTK, QT source code
- CMake: http://www.cmake.org/cmake/resources/software.html
- ITK: http://www.itk.org/ITK/resources/software.html
- VTK: http://www.vtk.org/VTK/resources/software.html
- QT: http://qt-project.org/downloads
- Note: In this tutorial, the used tool version numbers are listed here:
- cmake-2.8.10.2-win32-x86.exe
- InsightToolkit-4.2.1
- VTK5.10.1
- Qt4.8.4
- the main purpose of using cmake is taking the advantage of building a cross platform program
STEP TWO
- prons:
- organized and the binary codes for different platforms can be separated from each other
- easy maintenance
- easy upgrade
STEP THREE (main part of this tutorial)
<<build a 32bit environment>>
- build QT -> already done, leave this directory alone!!
- build ITK
- CMAKE PART
- using CMake to build the visual studio 2010 32-bit environment
- fill up the paths of source code and binary
- click the "Configure" button
- choose "Visual Studio 2010" and "Use default native compilers" and then click "Finish"
- wait a few minutes....
- Generally speaking, the message will show "Configuring done" like this snapshot:
- Remember: Just leave default setting, because those unchecked items are not being used here for now.
- click "Generate" button and wait for the "Generate done" message
- VISUAL STUDIO PART
- go to the build directory, e.g. "C:\itk\itk-4.2.1\vs10"
- open "ITK.sln"
- build them all under the Debug mode and Release mode
- wait a few minutes....( at lease one hour, depend on your machine )
- NOTE HERE: building on the release mode is necessary, because if we want to combine ITK and QT together, visual studio project need to be under the Release mode!!This is a tricky part.
- Until all the project being built successfully, the building process is over.
- build VTK( careful! )
- CMAKE PART
- using CMake to build the visual studio 2010 32-bit environment
- fill the paths of source code and binary up
- click the "Configure" button
- choose "Visual Studio 2010" and "Use default native compilers" and then click "Finish"
- wait a few minutes....
- Generally speaking, the message will show "Configuring done" like this snapshot:
- BE CAREFUL:
- CHECK BUILD_EXAMPLES ( for QT + VTK project test )
- CHECK BUILD_SHARED_LIBS ( for VTK work with QT )
- CHECK VTK_USE_QT ( for VTK library to build QT-related components)
- CHECK VTK_USE_GUISUPPORT ( you need to check the "Advanced" item first in order to see this setting)
- click "Configure" button AGAIN!!
- if everything goes well, then the result should look like this:
- click "Generate" button and wait for the "Generate done" message
- VISUAL STUDIO PART
- go to the build directory, e.g. "C:\vtk\VTK5.10.1\vs10"
- open "VTK.sln"
- build them all under the Release mode Release mode Release mode
- wait a few minutes....( the needed time depends on your machine )
- NOTE HERE: building on the release mode is necessary, because if we want to combine VTK and QT together, visual studio project need to be under the Release mode!!This is a tricky part.
- Until all the project being built successfully, the building process is over.
- QT SETUP PART
- go to "C:\vtk\VTK5.10.1\vs10\bin\Release" and check if there are two file name QVTKWidgetPlugin.lib and QVTKWidgetPlugin.dll
- (Note: if they are NOT there, then you must have not check BUILD_SHARED_LIBS)
- Copy QVTKWidgetPlugin.lib and QVTKWidgetPlugin.dll from "C:\vtk\VTK5.10.1\vs10\bin\Release" to C:\Qt\4.x.x\plugins\designer
- if everything goes well, then open the QT designer. You will find the VTK WINDOW WIDGET at the bottom of the qt widget list like this snapshot:
- ENVIRONMENT VARIABLE SETUP PART ( THE MOST IMPORTANT!!!!! )
- Add a new environment variable: QTDIR = C:\Qt\4.X.X (or whatever VERSION you installed QT)
- Append the environment variable PATH to add
- C:\Qt\4.8.4\bin
- C:\vtk\VTK5.10.1\vs10\bin\Release
STEP FOUR
- check whether the environment being setup correctly or not
- check ITK + VTK + QT
- check ITK + QT
- check VTK + QT
- in the VTK source code, there are a few examples can be used for checking under the Example folder
- Tutorial Projects
- EasyView
- SimpleView
- Qtevents
- qtimageviewer
- QtVTKRenderWindows
- EventQtSlotConnect
References and other useful links
- VTK/Tutorials/QtSetup http://www.vtk.org/Wiki/VTK/Tutorials/QtSetup
- VTK + QT examples http://www.vtk.org/Wiki/VTK/Examples/Cxx#Qt
2014/02/25 update