I want to run a ROS node using fcl library. I just wrote a small code and I edited the CMakeLists.txt to make sure that I can run the node but I got the following error:
/usr/bin/ld: cannot find -lfcl
collect2: error: ld returned 1 exit status
What should I do?
My CMakeLists.txt is the following:
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}
)
Replace fcl
by ${fcl_LIBRARIES}
in the link-command:
target_link_libraries(fcl_test
${fcl_LIBRARIES}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
)
If find_package(fcl REQUIRED)
works correctly, this variable should be automatically set.