error: undefined reference to `QVTKWidget::QVTKWidget(QWidget*, QFlags<Qt::WindowType>)'
-
I m using Qt5.15 in Ubuntu 20.04. I want to use PCL to visualise point cloud data. To get PCL runnig with Qt, VTK library is also required. So in my system I have PCL 1.10 and VTK 7.1.1. I have taken sample code for testing the setup from here. I m getting following error:
error: undefined reference to `QVTKWidget::QVTKWidget(QWidget*, QFlags<Qt::WindowType>)'
Any suggestion for resolving this?
-
@surajj4837 said in error: undefined reference to `QVTKWidget::QVTKWidget(QWidget*, QFlags<Qt::WindowType>)':
Any suggestion for resolving this?
Link against the VTK library
-
This could be a good time to take a look at Qt SUB_DIRS.
It does most of the grunt work for you.
It manages library source code , links to library...
However you still have to add source reference (include header) to
your library. Lack of it gives you "undefined reference " error.SUB_DIRS even lets you reuse existing code - importing from github.
-
@surajj4837 said in error: undefined reference to `QVTKWidget::QVTKWidget(QWidget*, QFlags<Qt::WindowType>)':
and linking it with Qt.
This link never tells you anything how to link against the VTK library. See qmake documentation on how to link against libs: LIBS
And forget about SUB_DIRS - it's not needed here at all (aart from the fact that even the name is wrong - it's SUBDIRS) -
@Christian-Ehrlicher I m using cmake build system.
-
Then take a look at find_library and target_link_libraries... There are enough examples out there for cmake.
-
I think the problem is, I m copying the libQVTKWidgetPlugin.so in /plugins/designer/ directory of Qt but the qt creator is not able to recognize it.
-
@surajj4837 If it is a plug-in for QtCreator then you need to copy it to the QtCreator plugin folder.
-
Official doc says libQVTKWidgetPlugin.so is required to be copied to plugins/designer directory, I have seen many setup tutorial pages which convey the same like this and this.