2013年2月27日 星期三

ITK + VTK + QT on Window 7 64bit and Visual Studio 2010 Pro 32bit project


STEP ONE

STEP TWO

  • Organize Source code
    • the recommended tree like this - 
      • library
        • library_version_number
          • library_source_code
          • library_build_platform1
          • library_build_platform2
          • library_build_platformX
    • for example:
    • 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>> 

  1. build QT -> already done, leave this directory alone!!
  2. build ITK
    1. 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
    2. 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.
  3. build VTK( careful! )
    1. 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
    2. 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.
    3. 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:
    4. 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
      1. EasyView
      2. SimpleView
      3. Qtevents
      4. qtimageviewer
      5. QtVTKRenderWindows
      6. EventQtSlotConnect



References and other useful links



2014/02/25 update