我想使用fcl库运行ROS节点。我刚刚编写了一个小代码,并编辑了CMakeLists.txt以确保我可以运行该节点,但是我收到了以下错误:
/usr/bin/ld: cannot find -lfcl
collect2: error: ld returned 1 exit status
我该怎么办?
我的CMakeLists.txt如下:
cmake_minimum_required(VERSION 2.8.3)
project(package_name)
find_path(FCL_INCLUDE_DIRS
NAMES fcl/collision.h
HINTS ${PC_FCL_INCLUDEDIR}
PATHS "${CMAKE_INSTALL_PREFIX}/include")
find_package(catkin REQUIRED COMPONENTS
nav_msgs
roscpp
sensor_msgs
visualization_msgs
tf
dynamic_reconfigure
message_generation
laser_geometry
geometry_msgs
cmake_modules
)
find_package(Boost REQUIRED)
find_package(Eigen REQUIRED)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(fcl REQUIRED)
generate_dynamic_reconfigure_options(
)
generate_messages(
DEPENDENCIES
geometry_msgs sensor_msgs nav_msgs visualization_msgs
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${haptic_teleoperation}
CATKIN_DEPENDS message_runtime nav_msgs roscpp sensor_msgs
DEPENDS eigen
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(include
${catkin_INCLUDE_DIRS}
${Eigen_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${FCL_INCLUDE_DIRS}
)
## Declare a cpp library
add_library()
add_executable(fcl_test src/fcl_test.cpp)
add_dependencies(fcl_test
${PROJECT_NAME}_gencfg
${PROJECT_NAME}_generate_messages_cpp
)
target_link_libraries(fcl_test
fcl
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
)
答案 0 :(得分:2)
在link-command中将fcl
替换为${fcl_LIBRARIES}
:
target_link_libraries(fcl_test
${fcl_LIBRARIES}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
)
如果find_package(fcl REQUIRED)
正常工作,则应自动设置此变量。