【问题标题】:#include <QtWidgets> not working in Qt 5.5 with ros kinetic ubuntu 16.06#include <QtWidgets> 在带有 ros kinetic ubuntu 16.06 的 Qt 5.5 中不起作用
【发布时间】:2017-06-08 10:37:46
【问题描述】:

我有一个 ros-project 可以在 ubuntu 14.04 上的 ros-indigo 下构建良好 现在我切换到 ros-kinetic 和 ubuntu 16.04,构建代码时出现以下错误:

错误 * [CMakeFiles/rviz_satellite.dir/src/moc_aerialmap_display.cpp.o] 错误 1 make[2]: 等待未完成的工作......在包含的文件中 /home/kohaf3/opel_ws/src/rviz_satellite/src/aerialmap_display.cpp:45:0: /home/kohaf3/opel_ws/src/rviz_satellite/src/aerialmap_display.h:43:21: 致命错误:QtWidgets:没有这样的文件或目录编译 终止。制作[2]: [CMakeFiles/rviz_satellite.dir/src/aerialmap_display.cpp.o] 错误1 make[1]: * [CMakeFiles/rviz_satellite.dir/all] 错误 2 make: *** [全部] 错误 2

我的 CMakeLists 文件如下:

cmake_minimum_required(VERSION 2.8.3)
project(rviz_satellite)

set(DISTRO $ENV{ROS_DISTRO})
message("Distribution: " ${DISTRO})

set(DEFAULT_BUILD_QT5 OFF)
if(${DISTRO} STREQUAL "kinetic")
    set(DEFAULT_BUILD_QT5 ON)
endif()

option(UseQt5 "Build w/ QT version 5" ${DEFAULT_BUILD_QT5})

if (UseQt5)
    find_package(Qt5 COMPONENTS Core Gui Network Concurrent REQUIRED)
        message("qt5 is used")
else()
    find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
    include(${QT_USE_FILE})
        message("qt4 is used")
endif()

find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)

pkg_check_modules(OGRE_OV OGRE OGRE-Overlay)

# Old versions of OGRE (pre 1.9) included OGRE-Overlay in the main package
# (i.e. there was no OGRE-Overlay component).  So if the above
# pkg_check_modules() failed, try looking for just OGRE.
if(NOT OGRE_OV_FOUND)
  pkg_check_modules(OGRE_OV REQUIRED OGRE)
endif()

find_package(catkin REQUIRED COMPONENTS
  nav_msgs
  roscpp
  rviz
  sensor_msgs
  geodesy
  rtkrcv_ros_tool# wichtig für include:#include <rtkrcv_ros_tool/GPS_rtklib.h>
)

#generate_messages(
 # DEPENDENCIES
 # std_msgs
#)

catkin_package(CATKIN_DEPENDS nav_msgs sensor_msgs )#message_runtime)



set(${PROJECT_NAME}_SOURCES
  src/aerialmap_display.cpp
  src/tileloader.cpp
  src/rviz_plot_markers.cpp
)

set(${PROJECT_NAME}_HEADERS
  src/aerialmap_display.h
  src/tileloader.h
)

# invoke MOC and UI/ include Qt headers/ link Qt libraries
if (UseQt5)
    qt5_wrap_cpp(${PROJECT_NAME}_MOCSrcs ${${PROJECT_NAME}_HEADERS})
    include_directories(
        ${Qt5Core_INCLUDE_DIRS}
        ${Qt5Gui_INCLUDE_DIRS}
        ${Qt5Network_INCLUDE_DIRS}
        ${Qt5Concurrent_INCLUDE_DIRS}
                "/usr/include/qt5"
        )
    link_libraries(
        ${Qt5Core_LIBRARIES}
        ${Qt5Gui_LIBRARIES}
        ${Qt5Network_LIBRARIES}
        ${Qt5Concurrent_LIBRARIES}
        )
else()
    qt4_wrap_cpp(${PROJECT_NAME}_MOCSrcs ${${PROJECT_NAME}_HEADERS})
    include_directories(${Qt4_INCLUDE_DIR})
    link_libraries(
        ${QT_LIBRARIES}
        )
endif()

# Other includes
include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${OpenCV_INCLUDE_DIR}
  ${OGRE_OV_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
  src
)

# Other libraries
link_libraries(
  ${QT_LIBRARIES}
  ${OpenCV_LIBRARIES}
  ${catkin_LIBRARIES}
)

add_definitions("-Wall -Wunused -std=c++11")

set(PROJECT_SOURCE_FILES
  ${${PROJECT_NAME}_SOURCES}
  ${${PROJECT_NAME}_MOCSrcs}
)

add_library(${PROJECT_NAME}
  ${PROJECT_SOURCE_FILES}
)

install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
    ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

install(FILES plugin_description.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

# von Markus:
add_executable(rviz_node
    src/rviz_plot_markers.cpp)
add_dependencies(rviz_node ${catkin_EXPORTED_TARGETS})
target_link_libraries(rviz_node
  ${catkin_LIBRARIES}
)

qmake --version

QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu

pkg-config --modversion QtCore

4.8.7

qtdiag

Library info:   PrefixPath: /usr   DocumentationPath: /usr/share/qt5/doc  
HeadersPath: /usr/include/x86_64-linux-gnu/qt5   LibrariesPath: /usr/lib
/x86_64-linux-gnu   LibraryExecutablesPath: /usr/lib/x86_64-linux-gnu/qt5
/libexec   BinariesPath: /usr/lib/x86_64-linux-gnu/qt5/bin   PluginsPath: 
/usr/lib/x86_64-linux-gnu/qt5/plugins   ImportsPath: /usr/lib/x86_64-
linux-gnu/qt5/imports   Qml2ImportsPath: /usr/lib/x86_64-linux-gnu/qt5/qml
ArchDataPath: /usr/lib/x86_64-linux-gnu/qt5   DataPath: /usr/share/qt5   
TranslationsPath: /usr/share/qt5/translations   ExamplesPath: /usr/lib
/x86_64-linux-gnu/qt5/examples   TestsPath: /usr/tests   
SettingsPath: /etc/xdg

我还安装了 Qt creator ros 插件,请参见此处 (https://github.com/ros-industrial/ros_qtc_plugin/wiki/1.-How-to-Install-(Users))

【问题讨论】:

    标签: c++ qt ubuntu qt5


    【解决方案1】:

    这对我有用:

    if (UseQt5)
            find_package(Qt5 COMPONENTS Core Gui Network Widgets Concurrent REQUIRED)
            message("qt5 is used")
            # Find Qt5Core and Qt5Widgets
            find_package(Qt5Core REQUIRED)
            find_package(Qt5Widgets REQUIRED)
            # For finding Qt includes
            include_directories(${CMAKE_CURRENT_SOURCE_DIR})
            include_directories(${Qt5Widgets_INCLUDE_DIRS})
            include_directories(${Qt5Core_INCLUDE_DIRS})
    
    else()
            find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtWidgets REQUIRED)
        include(${QT_USE_FILE})
            message("qt4 is used")
    endif()
    

    【讨论】:

      【解决方案2】:

      我认为您还必须在 CMake 中包含来自 Qt 的 Widgets/QtWidgets 模块:

      if (UseQt5)
          find_package(Qt5 COMPONENTS Core Gui Network Concurrent Widgets REQUIRED)
              message("qt5 is used")
      else()
          find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtWidgets REQUIRED)
          include(${QT_USE_FILE})
              message("qt4 is used")
      endif()
      

      【讨论】:

      • thatnks 有帮助 :) 但没用,您还必须包含目录。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-31
      • 2021-06-20
      • 1970-01-01
      • 2018-09-20
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      相关资源
      最近更新 更多