How to link Qt 5.9 in ROS? (Using Ubuntu 14.04)

asked 2017-12-09 02:53:33 -0500

Aquarius TheGirl gravatar image

updated 2017-12-10 22:55:05 -0500

The following CMakeList produces errors which have been listed below:

cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

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

project(draw_on_images)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)

find_package(OpenCV 2.4.8 REQUIRED)
find_package(Qt5 COMPONENTS Core Qml Quick REQUIRED)


qt5_add_resources(RESOURCES qml.qrc)

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

add_executable(${PROJECT_NAME} ${RESOURCES} src/main.cpp src/draw_on_qimage.cpp src/provide_qpixmap_to_qml.cpp )

qt5_use_modules(${PROJECT_NAME} Core Qml Quick)

target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Qml Qt5::Quick ${OpenCV_LIBS})

Below is the corresponding package.xml:

    <?xml version="1.0"?>
<package>

  <name>draw_on_images</name>
  <version>0.0.0</version>
  <description>The draw_on_images package</description>

  <maintainer email="...@todo.todo">...</maintainer>

  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>

  <export>
  </export>

</package>

Errors:

    :~/ros_workspace_test$ source devel/setup.bash 

    :~/ros_workspace_test$ catkin_make -DCMAKE_PREFIX_PATH="/opt/Qt5.9.1/5.9.1/gcc_64/lib/" -DWITH_QT:BOOL=ON

Base path: /home/.../ros_workspace_test
Source space: /home/.../ros_workspace_test/src
Build space: /home/..../ros_workspace_test/build
Devel space: /home/.../ros_workspace_test/devel
Install space: /home/.../ros_workspace_test/install
####
#### Running command: "cmake /home/.../ros_workspace_test/src -DCMAKE_PREFIX_PATH=/opt/Qt5.9.1/5.9.1/gcc_64/lib/ -DWITH_QT:BOOL=ON -DCATKIN_DEVEL_PREFIX=/home/.../ros_workspace_test/devel -DCMAKE_INSTALL_PREFIX=/home/.../ros_workspace_test/install -G Unix Makefiles" in "/home/.../ros_workspace_test/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/.../ros_workspace_test/devel
-- Using CMAKE_PREFIX_PATH: /opt/Qt5.9.1/5.9.1/gcc_64/lib/
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/..../ros_workspace_test/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.19
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - draw_on_images
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'draw_on_images'
-- ==> add_subdirectory(draw_on_images)
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    WITH_QT


-- Build files have been written to: /home/..../ros_workspace_test/build
####
#### Running command: "make -j4 -l4" in "/home/.../ros_workspace_test/build"
####
[ 14%] Automoc for target draw_on_images
[ 14%] Built target draw_on_images_automoc
Linking CXX executable /home/.../ros_workspace_test/devel/lib/draw_on_images/draw_on_images
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `int qmlRegisterType<Draw_on_qimage>(char const*, int, int, char const*)':
main.cpp:(.text._Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_[_Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_]+0x38): undefined reference to `Draw_on_qimage::staticMetaObject'
main.cpp:(.text._Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_[_Z15qmlRegisterTypeI14Draw_on_qimageEiPKciiS2_]+0x1b6): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `Draw_on_qimage::~Draw_on_qimage()':
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x13): undefined reference to `vtable for Draw_on_qimage'
main.cpp:(.text._ZN14Draw_on_qimageD2Ev[_ZN14Draw_on_qimageD5Ev]+0x25): undefined reference to `vtable for Draw_on_qimage'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `QMetaTypeIdQObject<Draw_on_qimage*, true>::qt_metatype_id()':
main.cpp:(.text._ZN18QMetaTypeIdQObjectIP14Draw_on_qimageLb1EE14qt_metatype_idEv[_ZN18QMetaTypeIdQObjectIP14Draw_on_qimageLb1EE14qt_metatype_idEv]+0x2c): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o: In function `QtPrivate::MetaObjectForType<Draw_on_qimage*, true>::value()':
main.cpp:(.text._ZN9QtPrivate17MetaObjectForTypeIP14Draw_on_qimageLb1EE5valueEv[_ZN9QtPrivate17MetaObjectForTypeIP14Draw_on_qimageLb1EE5valueEv]+0x7): undefined reference to `Draw_on_qimage::staticMetaObject'
CMakeFiles/draw_on_images.dir/src/main.cpp.o:(.data.rel.ro._ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE[_ZTVN11QQmlPrivate11QQmlElementI14Draw_on_qimageEE]+0x10): undefined reference to `Draw_on_qimage::metaObject() const'
CMakeFiles/draw_on_images ...
(more)
edit retag flag offensive close merge delete

Comments

Have you run setup.bash? source /opt/ros/kinetic/setup.bash (Or /indigo/ if you installed Indigo.)

clyde gravatar image clyde  ( 2017-12-09 15:08:49 -0500 )edit

@clyde please see the updated code.

Aquarius TheGirl gravatar image Aquarius TheGirl  ( 2017-12-10 22:30:27 -0500 )edit