-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the tutorial qt_visualizer compilation issue: qt4 -> qt5. #2051
Fix the tutorial qt_visualizer compilation issue: qt4 -> qt5. #2051
Conversation
But VTK can be compiled with both Qt4 and Qt5? |
In fact, it's possible that VTK can be compile with Qt4 or Qt5, but you can have trouble when you use binary packages available from Ubuntu repositories. When I look at the dependancies of the packages
When I look at the dependancies of the packages
So both Qt4 and Qt5 is installed. When I try to compile the example
Another user already identifies this issue. Roughly it said that you cannot have an executable that both link against Qt4 and Qt5. He chose to downgrade his version of VTK to be able to execute but I prefer to upgrade the example CMakeLists.txt to be able to compile with Qt5. PS: it's surprising that binaries available in the |
Ideally, we should check whether VTK was built with Qt4 or Qt5 and use the same. This information should be available in the That being said, I do not think that maintaining Qt4 compatibility is a priority for PCL and thus I'm fine with making Qt5 a strict requirement, at least in a tutorial code. @SergioRAgostinho opinions? |
I would actually migrate everything to Qt5, not only the tutorial code. |
I think that I can help to migrate all tutorial code (I think there is only two examples) in this merge request, but what do you mean exactly when you say "migrate everything"? Is it a big stuff? |
We have some apps and tools which are only QT4 compatible and I meant porting those. I would need to dig into all of our cmake files to be sure, but everything within CMake conditional blocks checking for |
I don't know if it helps, but I did a grep: grep -rn "QT4_FOUND" ~/wk/pcl_repo
/home/frozar/wk/pcl_repo/CMakeLists.txt:350: if (QT4_FOUND)
/home/frozar/wk/pcl_repo/CMakeLists.txt:352: endif (QT4_FOUND)
/home/frozar/wk/pcl_repo/gpu/people/tools/CMakeLists.txt:34:# if(QT4_FOUND AND VTK_USE_QVTK)
/home/frozar/wk/pcl_repo/apps/CMakeLists.txt:75: if (QT4_FOUND AND VTK_USE_QVTK)
/home/frozar/wk/pcl_repo/apps/CMakeLists.txt:88: endif (QT4_FOUND AND VTK_USE_QVTK)
/home/frozar/wk/pcl_repo/apps/CMakeLists.txt:149: if (QT4_FOUND AND VTK_USE_QVTK)
/home/frozar/wk/pcl_repo/apps/modeler/CMakeLists.txt:18:if(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/modeler/CMakeLists.txt:24:endif(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/cloud_composer/CMakeLists.txt:21:if(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/cloud_composer/CMakeLists.txt:27:endif(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/in_hand_scanner/CMakeLists.txt:8:if(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/point_cloud_editor/CMakeLists.txt:59:IF(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/point_cloud_editor/CMakeLists.txt:62:ELSE(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/apps/point_cloud_editor/CMakeLists.txt:65:ENDIF(NOT QT4_FOUND)
/home/frozar/wk/pcl_repo/cmake/pcl_find_qt5.cmake:77: set(QT4_FOUND TRUE) Question: |
I'd say lets keep this PR scoped in tutorial code. |
Same here. |
Besides, I'm not convinced that we need to remove Qt4 support at all. Right now it seems to work without issues, so why fixing something that is not broken :) |
Ok, I'll convert the example I think it's the only other Qt example, isn't it? |
The only, yet annoying, "issue" I faced so far was that Homebrew dropped support for Qt4, so on Mac, if you want meet this dependency you have to go compile it yourself. On trusty and xenial I think it's still there. On vcpkg it's only Qt5 as well. |
Seems so.
But PCL can be compiled with Qt5, what is the problem? |
Some of our shipped apps and tools only support Qt4. |
Ah, OK. Then I'd say the goal should be to update those to work with both versions (which is absolutely trivial in most cases). |
4fa5c74
to
56b6306
Compare
I adapted the CMake files of tutorials |
|
||
TARGET_LINK_LIBRARIES (colorize_cloud ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES}) | ||
TARGET_LINK_LIBRARIES (${PROJECT_NAME} ${QT_LIBRARIES} ${PCL_LIBRARIES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe explicitly linking against QT_LIBRARIES
is not needed, the qt5_use_modules
command below should take care of this.
Also, since you are rewriting most of the content anyway, can you please convert CMake function calls to lowercase? Uppercasing is an outdated practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Should I also take care of spaces before parenthesis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to convert everything regarding include_directories
, libraries
and definitions
to be target specific, i.e.target_include_directories
, target_link_libraries
and target_add_definitions
, because these allow to specify visibility to other things down the line. In this case it makes no difference because it's a super simple example but our newbie users simply copy things blindly and this would get them used to constraint definitions/headers/libraries to the intended targets.
|
||
TARGET_LINK_LIBRARIES (colorize_cloud ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES}) | ||
include_directories(${PCL_INCLUDE_DIRS}) | ||
link_directories(${PCL_LIBRARY_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectively, the link_directories
instruction is not required.
|
||
TARGET_LINK_LIBRARIES (pcl_visualizer ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES}) | ||
include_directories(${PCL_INCLUDE_DIRS}) | ||
link_directories(${PCL_LIBRARY_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same.
I'd argue that we as a library should provide our exported module targets with properly set up interface include directories, definitions, etc. so that the only thing the users need to do is write |
That is true, but that requires a massive rework in our CMake files. Nothing is adhering to that.. :/ |
…ointCloudLibrary#2051) Migration of qt_visualizer and qt_colorize_cloud tutorials to Qt5.
When I try to compile and execute the example
doc/tutorials/content/sources/qt_visualizer
, I got a mysterious and immediat error concerningrealloc()
. After some research I found this comment that describes the issue:https://stackoverflow.com/questions/36725763/c-realloc-invalid-pointer#comments-36725978
It's not possible to have a program that links to both Qt4 and Qt5 libraries. The dependance from Qt4 comes from the file CMakeLists.txt given as example, and the dependance from Qt5 comes from VTK library.
The purpose of this pull request is to provide an example of PCL using Qt5 as graphical interface, instead of Qt4.
Documentation ressources:
https://github.com/euler0/mini-cmake-qt/blob/master/CMakeLists.txt
http://doc.qt.io/qt-5/cmake-manual.html
https://wiki.qt.io/Using_CMake_build_system