Combine VTK and Qt with visual studio in Windows...
Software needed :
1. Qt (ex : iam using Qt 4.7.1 ) Download location : http://qt.nokia.com/downloads/
Note : download a setup that can be used with visual studio (ex: Qt libraries 4.7.3 for Windows (VS 2008, 230 MB))
2. vtk (ex : iam using vtk 5.6.1 ) Download location : http://www.vtk.org/VTK/resources/software.html#latest2
Note : Do not download the .exe file ,instead download the Source (that is in compressed form .zip)
3. visual studio (ex: iam using visual studio 2008 ) Download location : http://visual-studio-2008.en.malavida.com/ and their ar many other locations , you can try any.
4. cmake (ex: iam using cmake 2.8.3 ) Download location : http://code.google.com/p/cntc2/downloads/detail?name=cmake-2.8.3-win32-x86.exe&can=2&q=label%3ACMake.org
5: If you wanted to create qt projects in the visual studio then you can download add-in for it. Download : http://qt.nokia.com/downloads/visual-studio-add-in
Steps to Combine :
Install the Visual studio.
Install the Qt and set the environment variables for Qt (you can find these variables by opening qt command prompt).
open Qt command prompt , and type 'configure' and press enter and follow the steps.
we are all good ,if didn't find any error and command completed successfully.
Enter the command 'nmake' and hope for the successful completion without error. if command completed successfully then we are done with qt.
extract the content of vtk source (.zip file) to the selected location.
install cmake and run it. give the location of the folder that contains the extract of vtk source for source path and choose a folder location to build the binaries.After that press the configure button. after that you find a pop up ,that want's you to choose the generator for the project. choose the generator of visual studio as per version (ex : for my case 'visual studio 9 2008' ) and check the 'use default native compilers' and press the 'finish' button.
when 'configure' is complete you will find a screen like given below.
check the boxes 'vtk_uses_Qt' and other necessary boxes as per your requirement. After that press the button generate.On completion of 'generate' if you find some values in red, then again press 'configure' and on completion of 'configure' press 'generate'.
Now we are done with cmake, so close it.
Open the folder where you build the binaries for vtk. In this folder you find a file named 'VTK.sln'. Double click on that file (it will open with visual studio) and press the run button.now it will start compiling the vtk binaries.It will take very much time.
after successful completion of compilation you will see a screen like below and if you didn't find this screen then don't worry about it.the only thing that matters is successful compilation.
press 'cancel'. this is not of any use for us.
After that ,In solution explorer ,you can see INSTALL. right click on it and choose build only install and click it. By Default it will produce a folder in c:/program files/VTK and sometimes it produces error due to administrative privileges.if you find any error then,you just have to change the security permission for that folder and try again.
Hope for successful completion like this.
Now we are all good and there is no further chances of compilation error in combining of vtk with qt, because we don't have to compile any more. But we not done yet.
Go to the 'Tools' menu and choose 'Options'.After that,you will see a pop-up ,choose 'Visual c++ directories' from 'Projects and Solutions'.
Add the directories for 'Executable files','Include files','Library files' and 'Source files'. you can do it easily by seeing these screen shots.
1vtk = the folder where you install vtk.
1qt = the folder where you install Qt.
vtk1 = the folder that is created , when you run 'build only INSTALL'. By default it is in c:/program files/VTK.
Congratulations , you are done and able to work with Qt and vtk together.
Check it by compiling an example :
we are all good, but for confirmation we need to compile an example. So, you can download this example from the given location.
Download Location : http://iws45.iiita.ac.in/IIT2008067/ (here you find a folder named 'example' download it)
copy this folder in any selected location in your computer and open "visual studio command prompt" change the current directory in command prompt to the directory of example and run 'qmake -project'. after completion of command you will see a 'example.pro' file in example directory.Close the command prompt and open 'example.pro'. Edit it as given below.
change 'app' to 'vcapp'
add vtk include directory to the INCLUDEPATH
create a new variable LIBS and add all libraries of vtk to it.
Now open visual studio command prompt and change current directory to 'example'.Run the command 'qmake example.pro'. This will create 'example.vcproj'. double click on it. It will open with visual studio. Now click on run button and you will able to see the output.
Congratulations ,you just run an example that is using both Qt and vtk.
If you find any problem regarding combining of Qt and vtk. Just comment it here....
if you find this information useful then, please like it...