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

13 則留言:

  1. Thanks a bunch, man! I have to start a project that uses EXACTLY this configuration...I was stuck an entire week, trying to configure all togheter...Your guide really saved my life (that's be only, complete guide about this topic on the entire Net)! :-)
    Keep the good work with your blog!

    回覆刪除
  2. Thanks for your help. I think this is the only post about ITK + VTK + QT on Window 7 64bit and Visual Studio 2010 Pro 32bit project. Its really very help full . Thanks Again.

    回覆刪除
  3. where to add add QTDIR = C:\Qt\4.X.X??
    thank you.

    回覆刪除
    回覆
    1. 電腦->右鍵內容->進階系統設定->環境變數->系統變數->新增QTDIR, 然後輸入你的qt目錄位置!!

      刪除
  4. Hi thanks for the tutorial. I have one problem when run debug/release for itk.sln. It said AllBuild unsuccess? It is okay or I miss do something?

    回覆刪除
    回覆
    1. I am not pretty sure what the problem is
      Could you be more specific on that?

      刪除
  5. Nice post! Just wondering if Qt 5.2 and VTK 6.1 can be built in a same or similar way? Can you foresee any potential issue? Thanks

    回覆刪除
    回覆
    1. Thanks for your help, here is how I configure Qt5.2 and VTK6.1:
      http://linzhang-vision.blogspot.co.uk/2014/04/configure-vtk-61-qt-52-under-win7-32bit.html

      刪除
  6. Awesome post! Thanks a bunch :D

    回覆刪除
  7. Hello,

    this is a great post how ever I have a question. I'm new on QT and VTK and I saw your posts from qt forum as well. I'm working on a project that I need to open a dcm file via qt. But I counldn't figure it out. I was wondering if you can help. Nothing online is working. Thank you

    回覆刪除
  8. You mean, open a dcm file "directly" via qt?
    Qt has no API for opening a dcm file.
    The easiest and solid way is opened by ITK and then render it by VTK with showing widget of QT

    回覆刪除
  9. First of all thank you for your answer! I have the code to open with ITK (C++ code). And now I need to combine the code with VTK and show it QT widget. Can you help me with that? What I need is basically to have an interface to open dicom files that I have in my computer and have a tool bar at the bottom to slide through the slices. Thank you

    回覆刪除