ros - Ros catkin_make 使用 Qt 失败
问题描述
当我 catkin_make 我的工作区时出现此错误:
[100%] Linking CXX executable /home/ankilp/test_ws/devel/lib/lidar_depth/lidar_depth
/usr/bin/ld: cannot find -lQt5::Widgets
这是我的 CMakeList 文件:
cmake_minimum_required(VERSION 2.8.3)
project(lidar_depth)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
genmsg
)
find_package( PCL REQUIRED)
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_NO_KEYWORDS)
catkin_package(
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(${PROJECT_NAME} src/LidarDepth.cpp src/Projection_matrices.hpp)
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${QT_LIBRARIES}
)
我没有明确使用与 Qt 相关的任何内容。我单独安装了 Qt5,但问题仍然存在。是否有单独的过程将 Qt 链接到我的系统?
解决方案
看起来您至少在使用 ROS Kinetic(基于添加编译选项的注释)。Kinetic 中的大多数东西都依赖于 Qt5 而不是 Qt4。尝试对您的CMakeLists.txt
文件进行以下更改:
替换此行
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
用这些线
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
set(QT_LIBRARIES Qt5::Widgets)
如果这对您不起作用,请发表评论,因为我CMakeLists.txt
在 Kinetic 中有 Qt5 的工作文件,并且可能可以确定还需要更改哪些内容,但我认为这是要做的最小更改。