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

Using Qt Libraries with ROS Indigo CMake Error [closed]

asked 2015-07-01 13:40:54 -0500

jacob.t.hopkins gravatar image

updated 2015-07-02 18:55:17 -0500

130s gravatar image

I'm trying to incorporate an existing Qt GUI into a ROS node. I'm initially just trying to get the CMakeLists.txt to build successfully in QtCreator 2.7.2. I keep getting an error that:

CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:75 (find_package):
  Could not find a package configuration file provided by "Qt4" with any of
  the following names:

    Qt4Config.cmake
    qt4-config.cmake

  Add the installation prefix of "Qt4" to CMAKE_PREFIX_PATH or set "Qt4_DIR"
  to a directory containing one of the above files.  If "Qt4" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  armswing_ros/CMakeLists.txt:7 (find_package)

There are a few possible solutions suggested that I've tried, and I haven't been able to get things to work correctly yet. I added Qt4 COMPONENTS QtCore QTGui to the find_package() call, usr/include/qt4 to the include_directories() call, INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}), and a link to my package "armswing_ros" in the target_link_libraries() as such: armswing_ros ${QT_LIBRARIES}.

What do I need to do to get the Qt libraries available?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by jacob.t.hopkins
close date 2015-07-06 12:27:40.104413

Comments

Have you had any luck?

allenh1 gravatar image allenh1  ( 2015-07-04 13:26:40 -0500 )edit

Not so far. I was gone the end of last week so I've just started looking again. I'm not getting errors that libraries can't be found anymore, but I still don't have access to the necessary Qt components: QString, QFile, and QTextStream

jacob.t.hopkins gravatar image jacob.t.hopkins  ( 2015-07-06 11:25:48 -0500 )edit

Could you update your question with the Ubuntu version and the output of qmake --version?

allenh1 gravatar image allenh1  ( 2015-07-06 11:44:22 -0500 )edit

I managed to get it to work. The GUI was written using Qt4 libraries, which I couldn't import, but I could import Qt5 libraries, so I did. Then there was a bit of adding Qt4 directories back in where names had been changed and now it builds successfully. Thanks a bunch!

jacob.t.hopkins gravatar image jacob.t.hopkins  ( 2015-07-06 12:05:43 -0500 )edit

Absolutely! So this question may be closed?

allenh1 gravatar image allenh1  ( 2015-07-06 12:10:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-02 19:01:37 -0500

allenh1 gravatar image

Here's an example. This is a very simple Qt5 CMakeLists.txt file.

cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_BUILD_TYPE RELEASE)
project(ros_threading_example)
find_package(catkin REQUIRED COMPONENTS roscpp
                            message_generation
                                      nav_msgs)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)

add_message_files(FILES Pose2D.msg)
generate_messages(DEPENDENCIES std_msgs)

catkin_package(
  CATKIN_DEPENDS roscpp message_generation
  DEPENDS system-lib
)

qt5_wrap_cpp(QT_MOC_HPP src/RobotThread.h)

include_directories(src ${catkin_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})

add_executable(pose_echo_threaded src/main.cpp 
                                  src/RobotThread.cpp
                                  ${QT_RESOURCES_CPP}
                                  ${QT_MOC_HPP})

add_executable(pose_echo src/PoseEcho.cc)

add_dependencies(pose_echo ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(pose_echo_threaded ${PROJECT_NAME}_generate_messages_cpp)

target_link_libraries(pose_echo_threaded ${catkin_LIBRARIES} Qt5::Widgets)
target_link_libraries(pose_echo ${catkin_LIBRARIES})

install(TARGETS pose_echo_threaded pose_echo
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-01 13:40:54 -0500

Seen: 2,635 times

Last updated: Jul 02 '15