pcl icon indicating copy to clipboard operation
pcl copied to clipboard

LNK2019 unresolved external symbol "__declspec(dllimport) public:__cdeclQVTOpenGLNativeWidget::QVTKOpenGLNativeWidget(Class QWidget *, class QFlags<enum Qt::WindowsType>)" while using PCL-1.12.1-AllInOne-msvc2019-win64 binaries.

Open Mujadid-Ali opened this issue 2 years ago • 9 comments
trafficstars

Background We have a small app that shows Point Cloud points. previously our app was using PCL 1.9.1 with its dependencies (boots 1.59.0, Eigen 3.3.7, Flann 1.8.5, VTK 8.2.0 with qt 5.7.1, QHull 8.0.2, OpenNi2 2.2.0.33) and QVTKWidget for visualization. The App was working totally fine but we came to know that in the new version of VTK 9 the QVTKWidget is deprecated and if we update the PCL 1.12.1 version then we need to update the Widget from QVTKWidget to its alternative QVTKOpenGLNativeWidget.

Error Description So to update the PCL version from 1.9.1 to 1.12.1 we have downloaded PCL-1.12.1-AllInOne-msvc2019-win64 pre-build binaries from PCL's official GitHub release page. extracts all binaries with their dependencies updated our project CMake file and links new PCL binaries with our project first when we replaced #include <QVTKWidget.h> to #include <QVTKOpenGLNativeWidget.h> then this header file is not found. our Cmake and everything was correct. after some investigation, we discovered that the VTK version was packed with PCL-1.12.1-AllInOne-msvc2019-win64 pre-build binaries that are without QT support so that's why it does not have any GUI or QT-supported header files and libs. Then we build VTK 9.1 (with all of its GUI components) with QT 5.15 locally and place it in the PCL dependencies directory /3rdParty/VTK link will our App. the header not found issue is resolved but we got an undefined symbol error of newly updated widget QVTKOpenGLNativeWidget. image

Environment:

  • OS: Windows 11
  • Compiler: MSVC 2019
  • PCL Version: 1.12.1
  • PCL Type: Pre-build Binaries PCL-1.12.1-AllInOne-msvc2019-win64

Solution After some investigation, we found that QVTKOpenGLNativeWidget is defined in the GUISupportQt component of VTK while in PCLConfig.cmake (shipped with PCL-1.12.1-AllInOne-msvc2019-win64) at line 494 are not including VTK GUISupportQt component that's why we're getting undefined symbol errors. these are the components that are only included in shipped PCLConfig,cmake a file

# VTK components required by PCL
set(PCL_VTK_COMPONENTS "ChartsCore;CommonColor;CommonComputationalGeometry;CommonCore;CommonDataModel;CommonExecutionModel;CommonMath;CommonMisc;CommonTransforms;FiltersCore;FiltersExtraction;FiltersGeneral;FiltersGeometry;FiltersModeling;FiltersSources;ImagingCore;ImagingSources;InteractionImage;InteractionStyle;InteractionWidgets;IOCore;IOGeometry;IOImage;IOLegacy;IOPLY;RenderingAnnotation;RenderingCore;RenderingContext2D;RenderingLOD;RenderingFreeType;ViewsCore;ViewsContext2D;RenderingOpenGL2")

we have to update the above line with the following line which included all of the following VTK components GUISupportQt, GUISupportQtQuick, GUISupportQtSQL, RenderingQt, ViewsQt, CommonSystem;glew, RenderingUI, vtksys, freetype, kissfft, pugixml, loguru, InfovisCore, FiltersHybrid, FiltersTexture, ImagingGeneral;ImagingHybrid, FiltersStatistics, ParallelDIY, ParallelCore, ImagingColor, DICOMParser, metaio;png, tiff, zlib, jpeg;fmt, doubleconversion, IOXML, IOXMLParser, jsoncpp, lz4, lzma, and expat. as

set(PCL_VTK_COMPONENTS "ChartsCore;CommonColor;CommonComputationalGeometry;CommonCore;CommonDataModel;CommonExecutionModel;CommonMath;CommonMisc;CommonTransforms;FiltersCore;FiltersExtraction;FiltersGeneral;FiltersGeometry;FiltersModeling;FiltersSources;ImagingCore;ImagingSources;InteractionImage;InteractionStyle;InteractionWidgets;IOCore;IOGeometry;IOImage;IOLegacy;IOPLY;RenderingAnnotation;RenderingCore;RenderingContext2D;RenderingLOD;RenderingFreeType;ViewsCore;ViewsContext2D;RenderingOpenGL2;GUISupportQt;GUISupportQtQuick;GUISupportQtSQL;RenderingQt;ViewsQt;CommonSystem;glew;RenderingUI;vtksys;freetype;kissfft;pugixml;loguru;InfovisCore;FiltersHybrid;FiltersTexture;ImagingGeneral;ImagingHybrid;FiltersStatistics;ParallelDIY;ParallelCore;ImagingColor;DICOMParser;metaio;png;tiff;zlib;jpeg;fmt;doubleconversion;IOXML;IOXMLParser;jsoncpp;lz4;lzma;expat")

also after adding this the unresolved symbol error are resolved but io_ply.dll were not installing automatically so again we have to update PCLConfig,cmake at line 453 and 464 to add io_ply module so that its dll should automatically be installed. the line 453 and 464 were looks like this after updating

set(pcl_all_components  common kdtree octree search sample_consensus filters 2d geometry io io_ply features ml segmentation visualization surface registration keypoints tracking recognition stereo outofcore people)
set(pcl_io_int_dep common octree io_ply )

Suggestion My personal suggestion is that the pre-build binaries PCL-1.12.1-AllInOne- should work plug and play like manner. it should be packed and shipped with VTK (already build all of its modules with qt GUI support too) binaries and the above-required updates in PCLConfig.cmake file. if not that case then at least document the above steps in docs that how some new developer can use the above GUI components.

Refrence I have found the above solution only on the following page on the internet thanks to him for proving this solution https://mangoroom.cn/cpp/pcl-vtk9-x-viewer-hosted-on-qt-widget.html

Mujadid-Ali avatar Dec 27 '22 09:12 Mujadid-Ali

Hi, I'm not so familiar with the all-in-one installer since I don't use Windows, but if the VTK included in the all-in-one installer does not have Qt support, then PCL itself will also not contain classes that depend on QVTK and will also not have the corresponding items in PCL_VTK_COMPONENTS in PCLConfig.cmake. This is not an error. If you, in your own project and with the previously described situation, want to use for example QVTKOpenGLNativeWidget, then you will have to link to the necessary VTK library. There is no reason why PCL should link to a QVTK library like GUISupportQt for you in this situation.

That being said, I am not sure why the all-in-one installer does not have Qt/QVTK support. Maybe to not make the file size too large. Maybe @larshg or @UnaNancyOwen can comment on this.

Perhaps using vcpkg to install PCL could be an option for you, there you can select for which things (Qt, ...) you want support.

Regarding the problem with io_ply: not sure why that happens, I will look into it.

mvieth avatar Dec 30 '22 13:12 mvieth

@Mujadid-Ali Which CMake version are you using? Do you use static or dynamic libraries? What is the exact error message in the io_ply problem?

mvieth avatar Dec 30 '22 15:12 mvieth

Yes, the PCL included in the PCL All-in-one Installer is built with the Qt option disabled. The same is also the case for the VTKs included in it. If you want to use PCL with Qt, you need build PCL and QVTK (QVTK means VTK built with Qt enabled) from source code yourself. It is a bit out of date, My notes will be helpful to you. https://gist.github.com/UnaNancyOwen/59319050d53c137ca8f3#file-pcl1-13-0-md https://gist.github.com/UnaNancyOwen/77d61f9f21376c9b59fc#file-qvtk7-md

As mvieth says, One of the main reasons of PCL All-in-one Installer does not support Qt in default is file size. At this time, we do not have an active plan to change this.

UnaNancyOwen avatar Dec 30 '22 23:12 UnaNancyOwen

Thanks, @mvieth @UnaNancyOwen for quick reply. And sorry for my late reply If PCL All-in-one Installer does not support QT by default then it's fine for me, my point was just document this information somewhere it will save a lot of time for some new developers.

Mujadid-Ali avatar Jan 09 '23 05:01 Mujadid-Ali

@Mujadid-Ali Which CMake version are you using? Do you use static or dynamic libraries? What is the exact error message in the io_ply problem?

There were no errors during building, the error was at runtime when I run my application the io_ply.dll was missing. And now I got it since PCL All-in-one Installer does not support QT, so that's why they are not included in installing components.

Mujadid-Ali avatar Jan 09 '23 05:01 Mujadid-Ali

If PCL All-in-one Installer does not support QT by default then it's fine for me, my point was just document this information somewhere it will save a lot of time for some new developers.

@Mujadid-Ali Where would you have expected this information? Somewhere in the tutorials?

mvieth avatar Jan 09 '23 12:01 mvieth

@Mujadid-Ali Where would you have expected this information? Somewhere in the tutorials?

Yes, I think we should have a separate section here which explains how we can use PCL All-in-one Installer and what is included in it by default and what's not.

Mujadid-Ali avatar Jan 09 '23 13:01 Mujadid-Ali

@Mujadid-Ali Would you be interested in writing a tutorial for the All-in-one installer? Here are some more things that should be in such a tutorial: https://github.com/PointCloudLibrary/pcl/issues/4462

mvieth avatar Jan 09 '23 17:01 mvieth

@Mujadid-Ali Would you be interested in writing a tutorial for the All-in-one installer? Here are some more things that should be in such a tutorial: #4462

Sure, I'll do that as soon as I found some free time.

Mujadid-Ali avatar Jan 10 '23 07:01 Mujadid-Ali