Ask Your Question
0

PCL KdTree Undefined Symbol

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

23tg94 gravatar image

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

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)
edit retag flag offensive close merge delete

Comments

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.

MichaelKorn gravatar imageMichaelKorn ( 2015-11-09 06:21:28 -0600 )edit

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.

23tg94 gravatar image23tg94 ( 2015-11-09 07:44:52 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

You should try in CMakeLists.txt:

find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

and

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 688 times

Last updated: Nov 10 '15