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

tf linker error

asked 2014-11-10 04:39:23 -0500

Andrii Matviienko gravatar image

updated 2014-11-10 08:34:34 -0500

Hi all,

I have a linker issue while using tf library. Here is my callback. Without this only line in the callback there is NO linker error. Please, find below the linker error itself.

void callback (const sensor_msgs::PointCloud2ConstPtr& input)
  listener->waitForTransform("/world_base_link", (*input).header.frame_id, (*input).header.stamp, ros::Duration(5.0));

int main (int argc, char** argv)
  ros::init(argc, argv, "subscriber");
  ros::NodeHandle n;
  ros::Subscriber sub = n.subscribe("/kinect2/depth/points", 1, callback);
  ros::spin ();

Linker error:

Linking CXX executable range_image_border_extraction
CMakeFiles/range_image_border_extraction.dir/range_image_border_extraction.cpp.o: In function `callback(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&)':
range_image_border_extraction.cpp:(.text+0x18c): undefined reference to `tf::Transformer::waitForTransform(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::Time const&, ros::Duration const&, ros::Duration const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: ld returned 1 exit status
make[2]: *** [range_image_border_extraction] Error 1
make[1]: *** [CMakeFiles/range_image_border_extraction.dir/all] Error 2
make: *** [all] Error 2


cmake_minimum_required(VERSION 2.6 FATAL_ERROR)


find_package(PCL 1.7 REQUIRED)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg tf pcl_ros)


add_executable(range_image_border_extraction range_image_border_extraction.cpp)
target_link_libraries(range_image_border_extraction ${PCL_LIBRARIES})
target_link_libraries(range_image_border_extraction ${catkin_LIBRARIES})

Any ideas how to resolve this linker error?

edit retag flag offensive close merge delete


Please edit your question to include your CMakeLists.txt.

kmhallen gravatar image kmhallen  ( 2014-11-10 08:15:21 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-11-10 07:55:06 -0500

Andrii Matviienko gravatar image

Adding tf to find_package in CMakeLists.txt solved the problem. I had:

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)

Should be:

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg tf)
edit flag offensive delete link more

answered 2014-11-10 15:31:06 -0500

kmhallen gravatar image

catkin_package() is required:

Put catkin_package(CATKIN_DEPENDS roscpp rospy std_msgs genmsg tf pcl_ros) after find_package()

edit flag offensive delete link more


Thanks, but the problem is solved. Please find the answer below.

Andrii Matviienko gravatar image Andrii Matviienko  ( 2014-11-11 02:14:05 -0500 )edit

Question Tools

1 follower


Asked: 2014-11-10 04:39:23 -0500

Seen: 773 times

Last updated: Nov 10 '14