Undefined reference error while using PCL 1.8 with ROS Indigo
I am trying to use PCL 1.8 with ROS Indigo but getting Undefined reference error.
The PCL 1.8 is installed to a local directory from the source and it is working fine standalone. However, I am trying to use it in one of my ROS packages. Please see below CMakeLists.txt-
cmake_minimum_required(VERSION 2.8.3)
project(test_package)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
pcl_ros
pcl_conversions
)
set(PCL_FOLDER /home/baxterpc/Tools/pcl/release)
find_package(PCL 1.8 REQUIRED PATHS ${PCL_FOLDER} NO_DEFAULT_PATH)
catkin_package(
)
include_directories(
include
${PCL_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
MESSAGE(STATUS "PCL_VERSION: " ${PCL_VERSION})
add_library(sphere_detector src/sphere_detector.cpp)
target_link_libraries(sphere_detector ${PCL_LIBRARIES} ${catkin_LIBRARIES})
add_executable (sphere_detector_test src/sphere_detector_test.cpp)
target_link_libraries (sphere_detector_test sphere_detector ${PCL_LIBRARIES} ${catkin_LIBRARIES})
During compilation, it is showing PCL_VERSION: 1.8.1.99. Below is the error reported while running catkin_make-
[100%] Building CXX object test_package/CMakeFiles/sphere_detector_test.dir/src/sphere_detector_test.cpp.o
Linking CXX executable /home/baxterpc/ros_ws/devel/lib/test_package/sphere_detector_test
CMakeFiles/sphere_detector_test.dir/src/sphere_detector_test.cpp.o: In function `pcl::Feature<pcl::PointXYZRGB, pcl::Normal>::initCompute()':
sphere_detector_test.cpp:(.text._ZN3pcl7FeatureINS_11PointXYZRGBENS_6NormalEE11initComputeEv[_ZN3pcl7FeatureINS_11PointXYZRGBENS_6NormalEE11initComputeEv]+0x1b8): undefined reference to `pcl::search::KdTree<pcl::PointXYZRGB, pcl::KdTreeFLANN<pcl::PointXYZRGB, flann::L2_Simple<float> > >::KdTree(bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/baxterpc/ros_ws/devel/lib/test_package/sphere_detector_test] Error 1
make[1]: *** [test_package/CMakeFiles/sphere_detector_test.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
I am using Ubuntu 14.04 LTS 64 Bit PC. I want to know how to use PCL 1.8 inside ROS Indigo. Thanks!