ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

PCL KdTree Undefined Symbol

asked 2015-11-08 19:42:24 -0500

23tg94 gravatar image

updated 2015-11-09 14:45:04 -0500

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)

find_package(catkin REQUIRED COMPONENTS



add_executable(main src/main.cpp)
target_link_libraries(main ${catkin_LIBRARIES}  /usr/lib/
edit retag flag offensive close merge delete


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/

MichaelKorn gravatar image MichaelKorn  ( 2015-11-09 06:21:28 -0500 )edit

Thanks for the reply, I added to my CMakeLists.txt as so

target_link_libraries(main ${catkin_LIBRARIES} /usr/lib/

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.

23tg94 gravatar image 23tg94  ( 2015-11-09 07:44:52 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-11-10 04:41:16 -0500

You should try in CMakeLists.txt:

find_package(PCL REQUIRED)


target_link_libraries(main ${catkin_LIBRARIES} ${PCL_LIBRARIES})
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-11-08 19:42:24 -0500

Seen: 1,233 times

Last updated: Nov 10 '15