Rosanswers logo

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?

Originally posted by Andrii Matviienko on ROS Answers with karma: 56 on 2014-11-10

Post score: 0

Original comments

Comment by kmhallen on 2014-11-10:
Please edit your question to include your CMakeLists.txt.


1 Answer 1


Rosanswers logo

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) 

Originally posted by Andrii Matviienko with karma: 56 on 2014-11-10

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.