2

Is it possible to build qvtk library (and relatives) with qt5 and vtk 6.3 (or trunk version)?

I installed qt5 from the .run installer, everything installed fine, then I built vtk 6.3 from sources enabling VTK_Group_Qt and setting qt paths correctly.

There don't seem to be any specific option or module for QVTK (VTK widget for qt), so I'd assume it get built with this configuration, but when I try to compile some source code that relies on QVTK I get the errors:

/usr/bin/ld: cannot find -lvtkRendering
/usr/bin/ld: cannot find -lvtkGraphics
/usr/bin/ld: cannot find -lvtkHybrid
/usr/bin/ld: cannot find -lQVTK

Is there any way to build these libraries from VTK trunk? I couldn't find any indications anywhere.

Lake
  • 4,072
  • 26
  • 36

2 Answers2

2

I struggled with this problem for a long time, and it turns out it is a issue with the project's CMakeLists.txt.

I'll post here the wrong and correct versions for anyone who is struggling with the same problem:

WRONG:

cmake_minimum_required (VERSION 2.6 FATAL_ERROR)

project      (pcl-visualizer)
find_package (Qt5Wodgets)
find_package (VTK REQUIRED)
find_package (PCL 1.8 REQUIRED)

include_directories (${PCL_INCLUDE_DIRS})
link_directories    (${PCL_LIBRARY_DIRS})
add_definitions     (${PCL_DEFINITIONS})

set  (project_SOURCES main.cpp pclviewer.cpp)
set  (project_HEADERS pclviewer.h)
set  (project_FORMS   pclviewer.ui)
set  (VTK_LIBRARIES   vtkRendering vtkGraphics vtkHybrid QVTK)

QT5_WRAP_CPP (project_HEADERS_MOC   ${project_HEADERS})
QT5_WRAP_UI  (project_FORMS_HEADERS ${project_FORMS})

ADD_DEFINITIONS (${QT_DEFINITIONS})

ADD_EXECUTABLE  (pcl_visualizer ${project_SOURCES}
                                ${project_FORMS_HEADERS}
                                ${project_HEADERS_MOC})

TARGET_LINK_LIBRARIES (pcl_visualizer ${PCL_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES})

CORRECT:

cmake_minimum_required (VERSION 2.6 FATAL_ERROR)

project      (pcl-visualizer)
find_package (Qt5 REQUIRED COMPONENTS Widgets Core)
find_package (VTK REQUIRED)
find_package (PCL 1.8 REQUIRED)

include_directories (${PCL_INCLUDE_DIRS})
link_directories    (${PCL_LIBRARY_DIRS})
add_definitions     (${PCL_DEFINITIONS})

set  (project_SOURCES main.cpp pclviewer.cpp)
set  (project_HEADERS pclviewer.h)
set  (project_FORMS   pclviewer.ui)

QT5_WRAP_CPP (project_HEADERS_MOC   ${project_HEADERS})
QT5_WRAP_UI  (project_FORMS_HEADERS ${project_FORMS})

ADD_DEFINITIONS (${QT_DEFINITIONS})

ADD_EXECUTABLE  (pcl_visualizer ${project_SOURCES}
                                ${project_FORMS_HEADERS}
                                ${project_HEADERS_MOC})

TARGET_LINK_LIBRARIES (pcl_visualizer ${PCL_LIBRARIES})

qt5_use_modules (pcl_visualizer Widgets)

I'm not 100% sure about the reason of the problem, but my guess is that libQVTK and such was replaced in qt5 by the Qt5Widgets module (I wonder what libraries it refers to), making the old libraries unavailable and unneeded.

Lake
  • 4,072
  • 26
  • 36
0

You might want to look at this. In VTK's "CMakeLists.txt":

IF (VTK_USE_QT AND VTK_USE_GUISUPPORT AND VTK_USE_RENDERING)
  SET (VTK_USE_QVTK ON CACHE INTERNAL "Build QVTK widget and plugin for Qt" FORCE)
ELSE (VTK_USE_QT AND VTK_USE_GUISUPPORT AND VTK_USE_RENDERING)
  SET (VTK_USE_QVTK OFF CACHE INTERNAL "Build QVTK widget and plugin for Qt" FORCE)
ENDIF (VTK_USE_QT AND VTK_USE_GUISUPPORT AND VTK_USE_RENDERING)

So you should turn VTK_USE_QT, VTK_USE_GUISUPPORT, and VTK_USE_RENDERING ON when building VTK. (Last one should be ON by default) That being said, version 5.10.1's "CMakeLists.txt" might need some editing to link against Qt5.