We are working on migrating a project from Ubuntu 14.04 to Ubuntu 16.04, and we have encountered a problem when using a library called the PCL together with Qt. The symptom was that QtQuick and QtQml had several unreferenced functions when trying to build the project. The problem is now solved but has highlighted a behavior in Cmake that we do not understand.
The PCL 1.8.1 uses Qt 5.5.1 from the system (/usr/lib/x86_64-linux-gnu/cmake) – this is the default Qt version installed via apt-get packages. Now it turns our project uses Qt 5.9.1 (as a dependency) and the 2 Qt versions created a mismatch for Qt. A mismatch we do not understand.
We used to call the libraries in the following order :
# PCL
set(CMAKE_PREFIX_PATH ../Dependencies/pcl/v1.8.1)
find_package(PCL 1.7 REQUIRED COMPONENTS common io filters)
# Qt
set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed.
set(CMAKE_PREFIX_PATH ../Dependencies/Qt/v5.9.1/5.9.1/gcc_64)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5QuickControls2 REQUIRED)
We then printed the paths returned by the find_package instructions and we observed that the libraries used by the PCL (Qt5Widgets, Qt5Core, Qt5Gui, and Qt5OpenGL) were all referring to the old Qt 5.5.1 version. And the libraries only used by our executable were linking to the correct new Qt 5.9.1 version. This version mismatch caused a warning in Cmake and the build to fail with numerous link errors.
So we have changed the calling order and swapped Qt and the PCL:
# Qt
set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed.
set(CMAKE_PREFIX_PATH ../Dependencies/Qt/v5.9.1/5.9.1/gcc_64)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5QuickControls2 REQUIRED)
# PCL
set(CMAKE_PREFIX_PATH ../Dependencies/pcl/v1.8.1)
find_package(PCL 1.7 REQUIRED COMPONENTS common io filters)
With this configuration we didn’t have errors anymore. Hence our question: how come find_package did not find the correct Qt version in the 1st place?
How can you force find_package to look for packages in a given path? i.e. can we force find_package to override a path it previously knew?
Aucun commentaire:
Enregistrer un commentaire