Ask Your Question
0

Could not find or load the Qt platform plugin "windows" in ""

asked 2019-02-28 09:58:42 -0500

uPrizZ gravatar image

updated 2019-02-28 09:59:54 -0500

I am trying to build a Qt5 Widget application as a ROS2 package with colcon. After following this tutorial (only that I am using a Widget application instead of a quick app), I finally was able to compile the package, but I cannot run it because I get the following output:

c:\dev\ros2>ros2 run plainwidget plainwidget
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "".

Reinstalling the application may fix this problem.

I am using a custom package.xml and CMakeLists.txt as follows:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
    <name>plainwidget</name>
    <version>1.0.0</version>
    <description>
        Demo zum colcon builden eines Qt5 GUIs
    </description>
    <maintainer email="...@...">...</maintainer>
    <license>Apache License 2.0</license>

    <buildtool_depend>ament_cmake</buildtool_depend>

    <build_depend>rclcpp</build_depend>
    <build_depend>std_msgs</build_depend>
    <build_depend>qtbase5-dev</build_depend>
    <build_depend>qt5-qmake</build_depend>

    <exec_depend>libqt5-core</exec_depend>
    <exec_depend>rclcpp</exec_depend>
    <exec_depend>std_msgs</exec_depend>

    <export>
        <build_type>ament_cmake</build_type>
    </export>
</package>

...

cmake_minimum_required(VERSION 3.5)
project(plainwidget)

set (CMAKE_CXX_STANDARD 14)
if(NOT WIN32)
 set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -fPIC”)
endif()
IF (NOT DEFINED BUILD_VERSION)
 SET(BUILD_VERSION “not set”)
ENDIF()

ADD_DEFINITIONS(-DBUILD_VERSION=”${BUILD_VERSION}”)

find_package(ament_cmake REQUIRED)
find_package(example_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcutils)
find_package(rmw REQUIRED)
find_package(std_msgs REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

include_directories(
    ${rclcpp_INCLUDE_DIRS}
    ${std_msgs_INCLUDE_DIRS}
    ${Qt5Core_INCLUDE_DIRS}
    ${Qt5Gui_INCLUDE_DIRS}
    ${Qt5Widgets_INCLUDE_DIRS}
)

include_directories(src)
set(SOURCE_FILES
    src/main.cpp
    src/maingui.cpp
)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})

ament_target_dependencies(${PROJECT_NAME}
    "example_interfaces"
     "rclcpp"
     "rcutils"
     "std_msgs"
 )

target_link_libraries(${PROJECT_NAME}
 Qt5::Core
 Qt5::Gui
 Qt5::Widgets
 )

install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})

ament_package()

Maybe it has something to do with the entries under <build_depend> and <exec_depend>? I just took them out of the tutorial which is over 8 months old, so maybe something is outdated here. Where do I get the correct dependencies from which I Need to put into package.xml?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-01 15:14:32 -0500

uPrizZ gravatar image

Answer was to make use of Qt5's windeployqt feature. Setup cmd to find windeployqt (i.e. extend PATH by your Qt5 path) and then do

"windeployqt <ros2>/install/Lib/<package>/<target>.exe"

which will create all necessary dependencies, so you can run the Qt5 Project...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-02-28 09:58:42 -0500

Seen: 1,251 times

Last updated: Mar 01