ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Catkin/CMake Bundling for Snapcraft "Qrc module is not installed"

asked 2018-09-30 21:50:16 -0500

jared gravatar image

I'm working on bundling a ROS + Qt5 application into a snap - and can't seem to get all of the qt dependencies properly included. I would love to get some input on where I might be going wrong. I'm not certain if my problem is in Catkin/CMake, or Snapcraft.

Installing and running the snap launches the ROS nodes with no apparent issues. The Qt app; however, failes to open, giving me this:

QQmlImportDatabase::addImportPath: "/usr/lib/x86_64-linux-gnu/qt5/qml"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/usr/lib/x86_64-linux-gnu/qt5/qml"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/lib/x86_64-linux-gnu"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/opt/ros/kinetic/lib/demine_control_station"
QQmlApplicationEngine failed to load component
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed

The qml folder it's looking for doesn't exist in /snap/demine-control-station/x1/usr/lib/x86_64-linux-gnu/qt5/, which contains:
plugins

On my local machine; however, /usr/lib/x86_64-linux-gnu/qt5/ contains:
bin libexec mkspecs plugins qml

So - this leads me to believe that either I've either got my snapcraft.yaml wrong, or I'm missing an install() in my CMakelists.txt.

My understanding is that the find_package(), add_executable(), target_link_libraries() and, in the case of a qt app, qt5_use_modules() tell cmake what to install when I call install() on the project executable.

I'm still fairly inexperienced with cmake and Qt, and unfortunately a few full days of trial and error and digging through documentation hasn't cut it to figure out what I'm doing wrong. I did find this sage nugget though:

"Most ROS developers run out of the devel space. As a result, it's easy to forget the importance of good install rules"
(https://docs.snapcraft.io/build-snaps/ros)

Thanks a bunch!

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.8)
project(demine_control_station)

add_compile_options(-std=c++11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

##############################################################################
# Catkin
##############################################################################

find_package(catkin REQUIRED COMPONENTS qt_build roscpp sensor_msgs image_transport)
set(QML_IMPORT_PATH "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
set(QML_IMPORT_PATH2 "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
include_directories(${catkin_INCLUDE_DIRS})
catkin_package()

##############################################################################
# Qt Environment
##############################################################################

find_package(Qt5 COMPONENTS Core Gui Qml Quick REQUIRED)

##############################################################################
# Sections
##############################################################################

file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/${PROJECT_NAME}/*.hpp)

QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT5_WRAP_CPP(QT_MOC_HPP ${QT_MOC})

##############################################################################
# Sources
##############################################################################

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

##############################################################################
# Binaries
##############################################################################

add_executable(${PROJECT_NAME} ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
qt5_use_modules(${PROJECT_NAME} Quick Core)
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC include)

##############################################################################
# Installs
##############################################################################

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(
    DIRECTORY launch
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

And my snapcraft.yaml:

grade: devel
confinement: devmode

apps:
control-station:
    environment:
    QT_DEBUG_PLUGINS: 1
    QML_IMPORT_TRACE: 1
    command: desktop-launch roslaunch demine_control_station demine_control_station.launch ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-10-09 12:34:35 -0500

jared gravatar image

updated 2018-10-09 12:43:01 -0500

I did end up figuring this out. In case anyone else finds themselves in a similar boat, the problem was not related to catkin/cmake installs, but to the snapcraft setup. Qt plugins are not included automatically and have to be called out specifically under stage-packages (added directly after catkin-packages).

stage-packages:
  # Here for the plugins-- they're not linked in automatically.
  - libqt5core5a
  - libqt5gui5
  - libqt5quick5
  - qmlscene
  - qml-module-qtquick-controls

For the ROS plugin, I did a snapcraft dump to include the library.

edit flag offensive delete link more

Comments

+1 for posting your eventual solution.

Much appreciated.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-10 01:35:12 -0500 )edit

great job !! I'm in a similar situation....

astroteo gravatar image astroteo  ( 2018-10-22 09:53:30 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-09-30 21:50:16 -0500

Seen: 605 times

Last updated: Oct 09 '18