当我用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链接到我的系统?
答案 0 :(得分:1)
您似乎至少使用了ROS Kinetic(基于添加编译选项的注释)。 Kinetic depend on Qt5 instead of Qt4中的大多数内容。尝试对CMakeLists.txt
文件进行以下更改:
替换此行
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
带有这些行
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
set(QT_LIBRARIES Qt5::Widgets)
如果这对您不起作用,请留下评论,因为我在Kinetic中有一个适用于Qt5的CMakeLists.txt
文件,可以确定其他需要更改的地方,但是我认为这是需要进行的最小更改。
答案 1 :(得分:0)
如果单独安装了Qt,则必须告诉CMAKE在哪里可以找到您的安装。这可以通过在执行cmake(ref)之前在CMakeLists.txt文件内或在终端中指定CMAKE_PREFIX_PATH来完成。例如:
$ export CMAKE_PREFIX_PATH=/location/to/you/installation