PCL KdTree Undefined Symbol
Hello ROS Community,
I am fairly new to ROS but not to robotics or programming. I have been working with PCL and ROS and was trying to do a simple cluster extraction seen here. I can build and run the code but when I run the code I get the following error:
symbol lookup error: /var/CornholeRobot/devel/lib/cornhole_vision/main: undefined symbol: _ZN3pcl6search6KdTreeINS_8PointXYZEEC1Eb
My set up is:
- Ubuntu 14.04 LST
- ROS Indigo Latest Build
- PCL latest stable through apt-get
What I Have done:
- Followed all steps on this post
- Looked at every google post for the undefined symbol
Everything works fine except for when i try to use the KdTree in this line of code:
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
So for example I can run and execute planar segmentation to remove the ground plane perfectly fine.
I'm not sure if this is something i need to do in the CMakeLists.txt
file or maybe my includes are wrong?
Here are my includes (in the order that I have them):
#include <ros/ros.h>
#include <iostream>
#include <unistd.h>
//PCL Includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/features/normal_3d.h>
#include <pcl/search/kdtree.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/segmentation/extract_clusters.h>
If you have any information that could help me that would be great and if you need any additional information just let me know.
Thanks in advance.
PS: had to change the carets to quotes if someone can let me know if there is a way to use the carets (sideways v), in the forum, that would be great as well
Edit 1: Just in case anyone wants to see the CMakeLists.txt here it is:
cmake_minimum_required(VERSION 2.8.3)
project(cornhole_vision)
find_package(catkin REQUIRED COMPONENTS
pcl_conversions
pcl_ros
roscpp
sensor_msgs
)
catkin_package(
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_executable(main src/main.cpp)
target_link_libraries(main ${catkin_LIBRARIES} /usr/lib/libpcl_kdtree.so)
Undefined Symbol points to a missing library during Linking. So I suppose your includes are fine and you need to extend your CMakeLists.txt. With my installation I would need to link /usr/lib/libpcl_kdtree.so.
Thanks for the reply, I added libpcl_kdtree.so to my CMakeLists.txt as so
target_link_libraries(main ${catkin_LIBRARIES} /usr/lib/libpcl_kdtree.so)
I did check to make sure that was the correct path for me as well and it is. However when i add this nothing changes I get the same error.