Building QT, VTK and ITK on Windows 7 (X64)

In this post, I will write down step by step how to build qt, vtk ( Visualization Toolkit) and itk ( Insight Toolkit ) 64 bit on a windows 7 OS. Versions may be little outdated but all they are tested and working together like a charm.

  • TOOLS AND SDKs

  • INSTALLATION ORDER

    • Firstly, we have to install Microsoft Visual Studio 2012 Express Edition with online installer. After installing MSVC 2012 we are ready for building QT with 64 bit support. For building SDK’s (especially for VTK and ITK ) you can use the following pattern;
    • C:\sdk_name\machine_type\version_name\install \source \sdk_name-bin
  • BUILDING QT

    • For QT, we should use the following directory structure; C:\Qt\x64\4.8.4\ Extract the qt-everywhere-opensource-src-4.8.4.tar.gz to C:\Qt\x64\ and rename the folder name as 4.8.4
    • Open the command prompt with administrator privileges;
    • Start -> All Programs -> Microsoft Visual Studio 2012 -> Visual Studio Tools -> VS2012 x64 Cross Tools Command Prompt
    • Change Directory with the command C:\Windows\system32>cd C:\Qt\x64\4.8.4
    • Type the following configure command .If you are planning to use phonon, web-kit, script and multimedia modules you can remove some of the parameters For more information please visit – http://qt-project.org/doc/qt-4.8/modules.html
    • C:\Qt\x64\4.8.4\configure -opensource -shared -no-webkit -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-script -no-qt3support -platform win32-msvc2012
    • Type ( It can take about 1 hour – 2 hour depending on your cpu power. You should take a coffee break) C:\Qt\x64\4.8.4\nmake
    • Type ( It can take about 5 minutes ) C:\Qt\x64\4.8.4\nmake install
    • Install Qt Creator and launch the program;
    • From tools -> options -> Build & run -> Qt Versions : click the add button and browse the qmake.exe which is located on C:\Qt\x64\4.8.4\bin\qmake.exe
    • From tools -> options -> Build & run -> Kits : click the add button and choose the compiler “Microsoft Visual C++ Compiler 11.0 (amd64)” and the Qt version name you have just defined press apply and ok. Now you are ready for using Qt 4.8.4 with 64 bit support.
  • BUILDING VTK

    • Extract vtk-6.0.0.zip to C:\vtk\x64\6.0.0\ and rename the folder name as just “source” Create the directories install and vtk-bin on C:\vtk\x64\6.0.0\
    • CMAKE PHASE

      • Install Cmake and launch it
      • Browse the source as : C:\vtk\x64\6.0.0\source
      • Browse the build for binaries : C:\vtk\x64\6.0.0\vtk-bin
      • Click the configure button and choose the : “Visual Studio 11 Win64”
      • After finishing the configure phase check “Grouped” And “Advanced” boxes.
      • Uncheck BUILD -> BUILD_TESTING
      • Change CMAKE -> CMAKE_CONFIGURATION_TYPES as “Release”
      • Change CMAKE -> CMAKE_INSTALL_PREFIX as “C:\vtk\x64\6.0.0\install”
      • Check Module -> Module_vtkGUISupportQt
      • Check Module -> Module_vtkGUISupportQtOpenGL
      • Check VTK -> VTK_ALL_NEW_OBJECT_FACTORY
      • Check VTK -> VTK_Group_Imaging
      • Check VTK -> VTK_MAKE_INSTANTIATORS
      • Press again configure button, it will probably show an error press ok and continue
      • Change Ungrouped Entries -> QT_QMAKE_EXECUTABLE as “C:\Qt\x64\4.8.4\bin\qmake.exe”
      • Press again configure button it will populate QT configurations as red lines again. Check them
      • Press for last time configure button If there are no red lines
      • Press Generate button.
    • VISUAL STUDIO PHASE

      • Open the VTK.sln file from c:\vtk\x64\6.0.0\vtk-bin\VTK.sln
      • MSVC 2012 will open the project solution file, from solution explorer you should be able to see 123 projects.
      • Click ALL_BUILD project with right mouse button, from the menu click Build ( at this phase vtk library will be compiled this phase will take about 1-3 hours depending on your cpu power. Coffee break again)
      • If all of the projects are built successfully; Right click the INSTALL project and press build ( at this phase, compiled dlls, libs and include headers will be installed into C:\vtk\x64\6.0.0\install – That’s all you are ready to use VTK!
  • BUILDING ITK

    • Extract the InsightToolkit-4.4.0.zip file into C:\itk\x64\4.4.0\ and rename the extracted folder as source Create the directories install and itk-bin on C:\itk\x64\4.4.0\
    • CMAKE PHASE

      • Launch CMake, delete & reload cache – Browse the source as : C:\itk\x64\4.4.0\source – Browse the build for binaries : C:\itk\x64\4.4.0\itk-bin
      • Click the configure button and choose the : “Visual Studio 11 Win64”
      • After finishing the configure phase check “Grouped” And “Advanced” boxes.
      • Uncheck BUILD -> BUILD_EXAMPLES
      • Check BUILD -> BUILD_SHARED_LIBS
      • Uncheck BUILD -> BUILD_TESTING
      • Change CMAKE -> CMAKE_CONFIGURATION_TYPES as “Release”
      • Change CMAKE -> CMAKE_INSTALL_PREFIX as “C:\itk\x64\4.4.0\install”
      • Change ITK -> ITK_COMPUTER_MEMORY_SIZE as the amount of memory you are using in GB
      • Check ITK -> ITK_USE_64BITS_IDS
      • Check Module -> Module_ITKVtkGlue
      • Press again configure button; – Take a look at Ungrouped Entries -> VTK_DIR entry it should be “C:\vtk\x64\6.0.0\vtk-bin” If not set it.
      • Press again configure button and if there are no red lines anymore
      • Press Generate button.
    • VISUAL STUDIO PHASE

      • Open the ITK.sln file from c:\itk\x64\4.4.0\itk-bin\ITK.sln
      • MSVC 2012 will open the project solution file, from solution explorer you should be able to see 214 projects.
      • Click ALL_BUILD project with right mouse button, from the menu click Build ( at this phase itk library will be compiled this phase will take about 1-3 hours depending on your cpu power. Last coffee break)
      • If all of the projects are built successfully; Right click the INSTALL project and press build ( at this phase, compiled dlls, libs and include headers will be installed into C:\itk\x64\4.4.0\install – That’s all you are ready to use ITK!
  • USING QT-VTK-ITK ALL TOGETHER IN SAME PROJECT

    • Launch Qt Creator and create a Qt Project, to be able to use VTK and ITK libraries on that project you should add the following lines to your .pro file.
    • NOTE: Copy the binary dll files located on c:\vtk\x64\6.0.0\install\bin\ and c:\itk\x64\4.4.0\install\bin\ into the build folder of your project or you may add these folders to system wide PATH

     

DEFINES += "vtkRenderingCore_AUTOINIT=4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)"
DEFINES += "vtkRenderingVolume_AUTOINIT=1(vtkRenderingVolumeOpenGL)"
DEFINES += _CRT_SECURE_NO_WARNINGS

win32: LIBS += "advapi32.lib" "ws2_32.lib" "Rpcrt4.lib"

win32: LIBS += -LC:/vtk/x64/6.0.0/install/lib \
-lvtkChartsCore-6.0 \
-lvtkCommonColor-6.0 \
-lvtkCommonComputationalGeometry-6.0 \
-lvtkCommonCore-6.0 \
-lvtkCommonDataModel-6.0 \
-lvtkCommonExecutionModel-6.0 \
-lvtkCommonMath-6.0 \
-lvtkCommonMisc-6.0 \
-lvtkCommonSystem-6.0 \
-lvtkCommonTransforms-6.0 \
-lvtkDICOMParser-6.0 \
-lvtkDomainsChemistry-6.0 \
-lvtkFiltersAMR-6.0 \
-lvtkFiltersCore-6.0 \
-lvtkFiltersExtraction-6.0 \
-lvtkFiltersFlowPaths-6.0 \
-lvtkFiltersGeneral-6.0 \
-lvtkFiltersGeneric-6.0 \
-lvtkFiltersGeometry-6.0 \
-lvtkFiltersHybrid-6.0 \
-lvtkFiltersHyperTree-6.0 \
-lvtkFiltersImaging-6.0 \
-lvtkFiltersModeling-6.0 \
-lvtkFiltersParallel-6.0 \
-lvtkFiltersParallelImaging-6.0 \
-lvtkFiltersProgrammable-6.0 \
-lvtkFiltersSelection-6.0 \
-lvtkFiltersSources-6.0 \
-lvtkFiltersStatistics-6.0 \
-lvtkFiltersTexture-6.0 \
-lvtkFiltersVerdict-6.0 \
-lvtkGUISupportQt-6.0 \
-lvtkGUISupportQtOpenGL-6.0 \
-lvtkGeovisCore-6.0 \
-lvtkIOAMR-6.0 \
-lvtkIOCore-6.0 \
-lvtkIOEnSight-6.0 \
-lvtkIOExodus-6.0 \
-lvtkIOExport-6.0 \
-lvtkIOGeometry-6.0 \
-lvtkIOImage-6.0 \
-lvtkIOImport-6.0 \
-lvtkIOInfovis-6.0 \
-lvtkIOLSDyna-6.0 \
-lvtkIOLegacy-6.0 \
-lvtkIOMINC-6.0 \
-lvtkIOMovie-6.0 \
-lvtkIONetCDF-6.0 \
-lvtkIOPLY-6.0 \
-lvtkIOParallel-6.0 \
-lvtkIOSQL-6.0 \
-lvtkIOVideo-6.0 \
-lvtkIOXML-6.0 \
-lvtkIOXMLParser-6.0 \
-lvtkImagingColor-6.0 \
-lvtkImagingCore-6.0 \
-lvtkImagingFourier-6.0 \
-lvtkImagingGeneral-6.0 \
-lvtkImagingHybrid-6.0 \
-lvtkImagingMath-6.0 \
-lvtkImagingMorphological-6.0 \
-lvtkImagingSources-6.0 \
-lvtkImagingStatistics-6.0 \
-lvtkImagingStencil-6.0 \
-lvtkInfovisCore-6.0 \
-lvtkInfovisLayout-6.0 \
-lvtkInteractionImage-6.0 \
-lvtkInteractionStyle-6.0 \
-lvtkInteractionWidgets-6.0 \
-lvtkNetCDF-6.0 \
-lvtkNetCDF_cxx-6.0 \
-lvtkParallelCore-6.0 \
-lvtkRenderingAnnotation-6.0 \
-lvtkRenderingContext2D-6.0 \
-lvtkRenderingCore-6.0 \
-lvtkRenderingFreeType-6.0 \
-lvtkRenderingFreeTypeOpenGL-6.0 \
-lvtkRenderingGL2PS-6.0 \
-lvtkRenderingHybridOpenGL-6.0 \
-lvtkRenderingImage-6.0 \
-lvtkRenderingLOD-6.0 \
-lvtkRenderingLabel-6.0 \
-lvtkRenderingOpenGL-6.0 \
-lvtkRenderingVolume-6.0 \
-lvtkRenderingVolumeAMR-6.0 \
-lvtkRenderingVolumeOpenGL-6.0 \
-lvtkViewsContext2D-6.0 \
-lvtkViewsCore-6.0 \
-lvtkViewsGeovis-6.0 \
-lvtkViewsInfovis-6.0 \
-lvtkalglib-6.0 \
-lvtkexoIIc-6.0 \
-lvtkexpat-6.0 \
-lvtkfreetype-6.0 \
-lvtkftgl-6.0 \
-lvtkgl2ps-6.0 \
-lvtkhdf5-6.0 \
-lvtkhdf5_hl-6.0 \
-lvtkjpeg-6.0 \
-lvtkjsoncpp-6.0 \
-lvtklibxml2-6.0 \
-lvtkmetaio-6.0 \
-lvtkoggtheora-6.0 \
-lvtkpng-6.0 \
-lvtkproj4-6.0 \
-lvtksqlite-6.0 \
-lvtksys-6.0 \
-lvtktiff-6.0 \
-lvtkverdict-6.0 \
-lvtkzlib-6.0

INCLUDEPATH += C:/vtk/x64/6.0.0/install/include/vtk-6.0
DEPENDPATH += C:/vtk/x64/6.0.0/install/include/vtk-6.0

win32: LIBS += -LC:/itk/x64/4.5.0/install/lib \
-lITKBiasCorrection-4.5 \
-lITKBioCell-4.5 \
-lITKCommon-4.5 \
-lITKDICOMParser-4.5 \
-lITKEXPAT-4.5 \
-lITKFEM-4.5 \
-lITKIOBMP-4.5 \
-lITKIOBioRad-4.5 \
-lITKIOCSV-4.5 \
-lITKIOGDCM-4.5 \
-lITKIOGE-4.5 \
-lITKIOGIPL-4.5 \
-lITKIOHDF5-4.5 \
-lITKIOIPL-4.5 \
-lITKIOImageBase-4.5 \
-lITKIOJPEG-4.5 \
-lITKIOLSM-4.5 \
-lITKIOMRC-4.5 \
-lITKIOMesh-4.5 \
-lITKIOMeta-4.5 \
-lITKIONIFTI-4.5 \
-lITKIONRRD-4.5 \
-lITKIOPNG-4.5 \
-lITKIOSiemens-4.5 \
-lITKIOSpatialObjects-4.5 \
-lITKIOStimulate-4.5 \
-lITKIOTIFF-4.5 \
-lITKIOTransformBase-4.5 \
-lITKIOTransformHDF5-4.5 \
-lITKIOTransformInsightLegacy-4.5 \
-lITKIOTransformMatlab-4.5 \
-lITKIOVTK-4.5 \
-lITKIOXML-4.5 \
-lITKKLMRegionGrowing-4.5 \
-lITKLabelMap-4.5 \
-lITKMesh-4.5 \
-lITKMetaIO-4.5 \
-lITKNrrdIO-4.5 \
-lITKOptimizers-4.5 \
-lITKPath-4.5 \
-lITKPolynomials-4.5 \
-lITKQuadEdgeMesh-4.5 \
-lITKSpatialObjects-4.5 \
-lITKStatistics-4.5 \
-lITKVNLInstantiation-4.5 \
-lITKVTK-4.5 \
-lITKVideoCore-4.5 \
-lITKVideoIO-4.5 \
-lITKVtkGlue-4.5 \
-lITKWatersheds-4.5 \
-lITKgiftiio-4.5 \
-lITKniftiio-4.5 \
-lITKznz-4.5 \
-litkNetlibSlatec-4.5 \
-litkdouble-conversion-4.5 \
-litkgdcmCommon-4.5 \
-litkgdcmDICT-4.5 \
-litkgdcmDSED-4.5 \
-litkgdcmIOD-4.5 \
-litkgdcmMSFF-4.5 \
-litkgdcmjpeg12-4.5 \
-litkgdcmjpeg16-4.5 \
-litkgdcmjpeg8-4.5 \
-litkhdf5-4.5 \
-litkhdf5_cpp-4.5 \
-litkjpeg-4.5 \
-litkopenjpeg-4.5 \
-litkpng-4.5 \
-litksys-4.5 \
-litktiff-4.5 \
-litkv3p_lsqr-4.5 \
-litkv3p_netlib-4.5 \
-litkvcl-4.5 \
-litkvnl-4.5 \
-litkvnl_algo-4.5 \
-litkzlib-4.5

INCLUDEPATH += C:/itk/x64/4.5.0/install/include/ITK-4.5
DEPENDPATH += C:/itk/x64/4.5.0/install/include/ITK-4.5

3 thoughts on “Building QT, VTK and ITK on Windows 7 (X64)”

  1. Hi Chasank, thanks for your sharing. I’ve done everything as you said but ı’ve problem in cmake phase. cmkae can not find cxx c++ compiler. Can you help me ? Thanks for everything

    1. This might be because you have not selected the correct visual studio version. select Visual studio version which is installed on your system … i tried the above steps and i get perfect results

    2. I know the post is from 10/2015, but for everyone running into this problem:

      It is possible that Visual Studio is installed, but not the C++ Compiler!
      You can check/correct this by trying to create a new C++ project in Visual Studio. If the compiler is not yet installed, it will offer to download/install it. Afterwards, the problem should be solved.

Leave a Reply

Your email address will not be published. Required fields are marked *