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

Undefined reference error while using PCL 1.8 with ROS Indigo

asked 2018-02-13 09:33:04 -0600

ravijoshi gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-02-13 09:54:48 -0600

gvdhoorn gravatar image

updated 2018-02-14 02:27:37 -0600

Note: I'm not saying this is the cause of your issue, but you'll have to recompile all pkgs that depend on PCL from source anyway, you cannot mix the two versions.


Have you recompiled all pkgs that depend on PCL (pcl_conversions, pcl_ros, etc) from source using your custom PCL version (in /home/baxterpc/Tools/pcl/release)? If not, it could be your mixing PCL 1.7 with 1.8.x lib sets.


No. I haven't. Can you please tell me the steps to recompiled all packages that depend on PCL?

The most fool-proof method I know is:

  1. deinstall all packages that depend on libpcl-1.7-all and all libpcl-*-1.7 packages themselves (removing libpcl-1.7-all will probably already take those pkgs with it)
  2. create a catkin workspace (or reuse what you already have), clone the perception_pcl repository in it
  3. make sure to install all dependencies (but make sure to ask rosdep to ignore the libpcl-all-dev dependency (as it will try to make apt install v1.7, which we don't want)
  4. build the workspace (regular catkin_make or catkin build)

If you have any packages you deinstalled in step 1 but do still want/need, you'll have to build those from source in your catkin workspace as well (as all binary pkgs will try to use PCL 1.7).

See also #q252478 for the general workflow for building pkgs from sources.

Note that you'll have to make sure that /home/baxterpc/Tools/pcl/release is on the library/pkg search path, or you'll get errors on step 4, as no PCL can be found.

edit flag offensive delete link more

Comments

No. I haven't. Can you please tell me the steps to recompiled all packages that depend on PCL? Thank you very much.

ravijoshi gravatar image ravijoshi  ( 2018-02-13 19:15:55 -0600 )edit

Thank you very much. I tried to remove libpcl-1.7-all using synaptic package manager but I stopped in between. Since it was showing the complete removal of libpcl-1.7-all is going to remove ros-indigo-desktop-full package. See here.

ravijoshi gravatar image ravijoshi  ( 2018-02-14 03:20:50 -0600 )edit

well, yes, that is to be expected. If you want to do this right, you'll have to remove those packages and build them from sources, or you run the risk programs crashing with SEGFAULTs etc.

You can try to do what I described without removing the PCL 1.7 pkgs, but you'll have to be very careful.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-14 03:24:21 -0600 )edit
1

An alternative might be to use a suitable Docker container for this.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-14 03:24:50 -0600 )edit

Thank you very much.

ravijoshi gravatar image ravijoshi  ( 2018-02-14 05:16:27 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-02-13 09:33:04 -0600

Seen: 1,858 times

Last updated: Feb 14 '18