Results 1 to 17 of 17

Thread: QT (not-) working with VTK libraries

  1. #1
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QT (not-) working with VTK libraries

    hi there friendly qt centre,

    another newbie question...

    I'm trying to get vtk working with qt. I should also admit that I'm a nooby, so go easy. I'm trying to learn c++ for myself and have chosen the following configuration to get started;
    OS: XP
    toolkit: QT 4.5.1
    IDE: QT Creator 1.2

    VTK: 5.4.0

    I downloaded and decompressed VTK "C:\vtk-5.4.0" on my system. I followed the instructions over on QT Forums to build VTK with cmake. I didn't forget to set VTK_USE_GUISUPPORT and VTK_USE_QVTK. I gave cmake the location of the source "C:/vtk-5.4.0" and specified a place to build the libraries "C:/vtk".

    Thinking everything had gone smoothly, I proceeded with the simplest program I could get away with. The main class in my project is called VTK_Example.

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "vtk_example.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. VTK_Example w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    VTK_example.cpp
    Qt Code:
    1. #include "vtk_example.h"
    2. #include <QVTKWidget.h>
    3. #include <vtkRenderer.h>
    4. #include <vtkRenderWindow.h>
    5. #include "ui_vtk_example.h"
    6.  
    7. VTK_Example::VTK_Example(QWidget *parent)
    8. : QMainWindow(parent), ui(new Ui::VTK_Example)
    9. {
    10. ui->setupUi(this);
    11.  
    12. QVTKWidget* vtkWidget;
    13. vtkRenderer* ren;
    14. vtkWidget = new QVTKWidget(this,QFlag(0));
    15. ui->verticalLayout->addWidget(vtkWidget);
    16. ui->verticalLayout->update();
    17. ren = vtkRenderer::New();
    18. vtkWidget->GetRenderWindow()->AddRenderer(ren);
    19. ren->SetBackground(1.0,0,0);
    20. ren->Render();
    21. }
    22.  
    23. VTK_Example::~VTK_Example()
    24. {
    25. delete ui;
    26. }
    To copy to clipboard, switch view to plain text mode 

    I included the following lines in my VTK_App.pro
    Qt Code:
    1. LIBS += -LC:/vtk -lvtkCommon -lvtksys -lQVTK -lvtkQtChart -lvtkViews -lvtkWidgets -lvtkInfovis -lvtkRendering -lvtkGraphics -lvtkImaging -lvtkIO -lvtkFiltering -lvtklibxml2 -lvtkDICOMParser -lvtkpng -lvtkpng -lvtktiff -lvtkzlib -lvtkjpeg -lvtkalglib -lvtkexpat -lvtkverdict -lvtkmetaio -lvtkNetCDF -lvtksqlite -lvtkexoIIc -lvtkftgl -lvtkfreetype -lvtkHybrid
    2.  
    3. INCLUDEPATH += C:/vtk
    To copy to clipboard, switch view to plain text mode 

    When I try to build this simple program, I get the following errors;


    Qt Code:
    1. C:/<snip>/code/VTK_App/vtk_example.cpp:2: QVTKWidget.h: No such file or directory
    2. C:/<snip>/code/VTK_App/vtk_example.cpp:2: vtkRenderer.h: No such file or directory
    3. C:/<snip>/code/VTK_App/vtk_example.cpp:2: vtkRenderWindow.h: No such file or directory
    4. ...
    To copy to clipboard, switch view to plain text mode 

    One of my theories is that cmake hasn't built VTK correctly. My C:\vtk\bin folder is completely empty.

    Can anyone shed some light on where I've gone astray?

    Any help would be greatly appreciated.

    All the best,
    floyd

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    The fact that VTK's bin directory is empty doesn't say much. In general I would expect their stuff to be in c:/vtk/lib and c:/vtk/include. Your vtk include path is probably c:/vtk/include or something like that.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Thanks franz,

    I also looked around the vtk folder for places that should be in the include path, but the folder does not have an include folder or a lib folder. Here is the contents of my C:/vtk directory

    Qt Code:
    1. Contents of folder: C:\vtk 13/08/2009 7:31 AM
    2.  
    3. Date Time Attrib Bytes File name
    4. ---------- -------- ------ ---------------- --------
    5. C:\vtk
    6. 12/08/2009 3:54:46 PM -D---- bin
    7. 12/08/2009 9:28:02 PM -D---- CMake
    8. 12/08/2009 9:28:12 PM A----- 70,461 CMakeCache.txt
    9. 12/08/2009 9:28:41 PM -D---- CMakeFiles
    10. 12/08/2009 3:43:29 PM -D---- CMakeTmp
    11. 12/08/2009 3:54:46 PM A----- 11,429 cmake_install.cmake
    12. 12/08/2009 9:28:28 PM -D---- Common
    13. 12/08/2009 9:28:02 PM A----- 43 CTestCustom.cmake
    14. 12/08/2009 3:54:46 PM A----- 1,068 CTestTestfile.cmake
    15. 12/08/2009 3:42:03 PM A----- 1,745 DartConfiguration.tcl
    16. 12/08/2009 9:28:40 PM -D---- Examples
    17. 12/08/2009 9:28:29 PM -D---- Filtering
    18. 12/08/2009 9:28:30 PM -D---- GenericFiltering
    19. 12/08/2009 9:28:33 PM -D---- Geovis
    20. 12/08/2009 9:28:30 PM -D---- Graphics
    21. 12/08/2009 9:28:33 PM -D---- GUISupport
    22. 12/08/2009 9:28:32 PM -D---- Hybrid
    23. 12/08/2009 9:28:29 PM -D---- Imaging
    24. 12/08/2009 9:28:32 PM -D---- Infovis
    25. 12/08/2009 9:28:31 PM -D---- IO
    26. 12/08/2009 9:28:19 PM A----- 53,288 Makefile
    27. 12/08/2009 3:53:49 PM A----R 1,108 proj_config.h
    28. 12/08/2009 9:28:31 PM -D---- Rendering
    29. 12/08/2009 3:42:03 PM -D---- Testing
    30. 12/08/2009 3:42:12 PM A----R 1,347 UseVTK.cmake
    31. 12/08/2009 9:28:20 PM -D---- Utilities
    32. 12/08/2009 9:28:33 PM -D---- Views
    33. 12/08/2009 9:28:31 PM -D---- VolumeRendering
    34. 12/08/2009 3:41:41 PM A----- 1,392 VTKBuildSettings.cmake
    35. 12/08/2009 3:43:32 PM A----R 415 vtkCommonInstantiator.h
    36. 12/08/2009 9:28:03 PM A----- 2,978 VTKCompileToolsConfig.cmake
    37. 12/08/2009 3:53:57 PM A----R 8,888 VTKConfig.cmake
    38. 12/08/2009 3:53:15 PM A----R 752 VTKConfigQt.cmake
    39. 12/08/2009 3:53:47 PM A----R 7,632 vtkConfigure.h
    40. 12/08/2009 3:43:32 PM A----R 439 vtkFilteringInstantiator.h
    41. 12/08/2009 3:43:34 PM A----R 496 vtkGenericFilteringInstantiator.h
    42. 12/08/2009 3:43:37 PM A----R 415 vtkGeovisInstantiator.h
    43. 12/08/2009 3:43:33 PM A----R 431 vtkGraphicsInstantiator.h
    44. 12/08/2009 3:43:36 PM A----R 415 vtkHybridInstantiator.h
    45. 12/08/2009 3:43:33 PM A----R 423 vtkImagingInstantiator.h
    46. 12/08/2009 3:43:36 PM A----R 423 vtkInfovisInstantiator.h
    47. 12/08/2009 3:43:34 PM A----R 383 vtkIOInstantiator.h
    48. 12/08/2009 9:28:12 PM A----- 5,784 VTKLibraryDepends.cmake
    49. 12/08/2009 3:43:35 PM A----R 439 vtkRenderingInstantiator.h
    50. 12/08/2009 9:28:02 PM -D---- vtkstd
    51. 12/08/2009 3:42:12 PM A----R 4,890 vtkToolkits.h
    52. 12/08/2009 3:43:37 PM A----R 407 vtkViewsInstantiator.h
    53. 12/08/2009 3:43:36 PM A----R 487 vtkVolumeRenderingInstantiator.h
    54. 12/08/2009 3:43:36 PM A----R 423 vtkWidgetsInstantiator.h
    55. 12/08/2009 9:28:32 PM -D---- Widgets
    56. 12/08/2009 9:28:20 PM -D---- Wrapping
    57. -------------------
    58. 178,401 28 Files
    59.  
    60. Summary of C:\vtk
    61. Directories = 1
    62. Files = 28
    63. Bytes = 178,401
    To copy to clipboard, switch view to plain text mode 

    This is what leads me to believe that VTK has not been built correctly. Also, what should I be looking for?? Should I be looking for some .so files?

    Thanks again,
    floyd

  4. #4
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    At least the files you require aren't there. On windows you should be looking for DLL files. Did the vtk build produce any errors?

    I might have a shot at this when I get home.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  5. #5
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Thanks franz,

    I think I've found the error...another one of those embarassing newbie mistakes which i'm kicking myself for.

    I'm afraid I didn't realise I needed to actually *build* the files that cmake generated!

    Right now, the files are currently (24%) being built using QT Creator. For those who might also be in a similar situation...here's what I did.

    I opened QT Creator...selected 'New Project' and from the list, selected 'Import of Makefile-based Project'.

    I then chose a name for the project, vtk and specified the location to be the location of my generated files from cmake, C:\vtk.

    The project opened up with the file tree from that folder. I then selected Projects on the left hand side and changed the Toolchain from gcc to mingw.

    Now if is building the files and placing the dll's and dll.a files into C:\vtk\bin directory.

    I suppose that this is the solution to my problem...but I'll confirm when the build is completed.

    Thanks for all the advice franz, but hopefully this will solve the problem.

  6. #6
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    OK...it still has't worked.

    I'm having trouble making QT Creator find the libraries. I've appended the pro file with the following
    Qt Code:
    1. LIBS += -LC:/vtk/bin -lvtkCommon -lvtksys -lQVTK -lvtkQtChart -lvtkViews -lvtkWidgets -lvtkInfovis -lvtkRendering -lvtkGraphics -lvtkImaging -lvtkIO -lvtkFiltering -lvtklibxml2 -lvtkDICOMParser -lvtkpng -lvtkpng -lvtktiff -lvtkzlib -lvtkjpeg -lvtkalglib -lvtkexpat -lvtkverdict -lvtkmetaio -lvtkNetCDF -lvtksqlite -lvtkexoIIc -lvtkftgl -lvtkfreetype -lvtkHybrid
    2.  
    3. INCLUDEPATH += C:/vtk
    To copy to clipboard, switch view to plain text mode 

    Can anyone tell me what else I need to do? Should I create an environmental variable called LD_LIBRARY_PATH to point to the vtk\bin directory?

    Thanks again,
    floyd

  7. #7
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    Quote Originally Posted by floyd.pepper View Post
    I think I've found the error...another one of those embarassing newbie mistakes which i'm kicking myself for.

    I'm afraid I didn't realise I needed to actually *build* the files that cmake generated!
    Hey, we live and we learn.

    Quote Originally Posted by floyd.pepper View Post
    I'm having trouble making QT Creator find the libraries.

    Can anyone tell me what else I need to do? Should I create an environmental variable called LD_LIBRARY_PATH to point to the vtk\bin directory?
    What you need to do depends on what the exact problem is that you are experiencing. If Qt creator doesn't do the autocompletion or doesn't find the header files, make sure your INCLUDEPATH is correct. If you experience linker errors, then you should double check your libraries, although I think those won't be much of a problem.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  8. #8
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    It appears to be a problem with the INCLUDEPATH. The problem is that I don't have an 'include' folder that contains all the header files.

    In CMake I changed the CMAKE_INSTALL_PREFIX to point to a location C:/vtk-build in the hope that I would get an 'include' folder there which would contain all the header files for vtk. How else can I specify the header file? Do I need to locate and specify each header in the INCLUDEPATH? This would mean that my includepath would have as many entries as header files that I am using. I'm sure there must be an easier way?

    Thanks in advance for any pointers. Otherwise, have a great weekend!

    floyd

  9. #9
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    I'd just do a search for one or two specific headers you need in the VTK path. I haven't had time to do this myself, but I'm sure that if you do a quick search for vtkRenderer.h or something, you would come up with something useful.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  10. #10
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Hi Franz,

    I did a search as you recommended. I found the header file only in the original source that I downloaded from VTK, "C:\vtk-5.4.2\Rendering". I don't understand how the libraries (dlls) can be built correctly and placed in the C:\vtk\bin folder while the header files are not collected into one folder?

    As always, any comments or tips would be really appreciated.

    All the best,
    floyd



    (Apologies for the second post, I felt it was a different problem. I realise that this is not a problem with QT and VTK compatability, but instead seems to have been a problem with how I built VTK. Thanks for the comments.)

  11. #11
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Is it possible for me to bump this topic?

    If we come up with a solution, I would be very grateful.

    cheers,

  12. #12
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    Try:
    $ make install
    (replace make with whatever make tool you use at the moment)

    It might create the include directory for you. I haven't gotten round to trying to build VTK myself.
    Last edited by franz; 26th August 2009 at 21:05. Reason: updated contents
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  13. #13
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Hi Franz,

    I appreciate you getting back to me. I'm not sure how I can make install?

    1. After I have generated the files with cmake.
    2. I open up qtcreator and create a new project from the Makefile that cmake has just generated.
    3. I build the project using mingw; this creates the dll and dll.a in the bin directory. There is no include directory generated.

    Can you tell me what else I need to do? Do you think I should use cygwin bash to 'make install'? I presumed that qtcreator and mingw would be able to create the dll's and place all the header files in include directory.

    as always, your help is appreciated.

    All the best,
    floyd

  14. #14
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    ok, slight advance.

    Once qtcreator has finished building and created the dlls. I then try to run (I'm thinking that this is the same as 'make install'?)

    However, in the run settings it asks me for an executable. What executable would it be looking for?

    This problem has me stomped now since Aug 12th...I know Einstein said,'It`s not that I`m so smart, it`s just that I stay with problems longer.' but this is ridiculous.

    Cheers,

  15. #15
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    You can't do make install with qt creator. Open the qt command prompt, cd to the vtk directory and type mingw32-make install. At least, I think it was mingw32-make.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  16. #16
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT (not-) working with VTK libraries

    Thanks Franz,

    You just made my weekend That did the trick. I think my problem is solved. I started a qt command prompt and did mingw32-make install and I got everything installed into the 'include', 'lib', 'plugins' and 'bin' directory.

    Cheers Franz!

  17. #17
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT (not-) working with VTK libraries

    Great! Happy VTK'ing.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  2. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  3. Replies: 2
    Last Post: 8th March 2007, 22:22
  4. Qt 3.3 libraries
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st December 2006, 17:25
  5. Replies: 4
    Last Post: 7th March 2006, 08:52

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.