Ask Your Question

Problem with tf tutorial

asked 2019-03-25 11:30:47 -0500

calvintanct gravatar image

updated 2019-03-26 14:44:46 -0500

jayess gravatar image

I followed the tutorial

I encountered this error while doing catkin_make

CMakeFiles/turtle_tf_broadcaster.dir/src/turtle_tf_broadcaster.cpp.o: In function `poseCallback(boost::shared_ptr<turtlesim::Pose_<std::allocator<void> > const> const&)':
turtle_tf_broadcaster.cpp:(.text+0x57): undefined reference to `tf::TransformBroadcaster::TransformBroadcaster()'
turtle_tf_broadcaster.cpp:(.text+0x211): undefined reference to `tf::TransformBroadcaster::sendTransform(tf::StampedTransform const&)'
collect2: error: ld returned 1 exit status
learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/build.make:113: recipe for target '/home/calvin/catkin_ws/devel/lib/learning_tf/turtle_tf_broadcaster' failed
make[2]: *** [/home/calvin/catkin_ws/devel/lib/learning_tf/turtle_tf_broadcaster] Error 1
CMakeFiles/Makefile2:1482: recipe for target 'learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/all' failed
make[1]: *** [learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

I don't think I have problem with the CMakeLists but to just make sure

I put

find_package(catkin REQUIRED COMPONENTS


add_executable(turtle_tf_broadcaster src/turtle_tf_broadcaster.cpp)
target_link_libraries(turtle_tf_broadcaster ${catkin_LIBRARIES})

and my package.xml looks has this inside


Please tell me what is the error with this?

Complete CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS

#  INCLUDE_DIRS include
#  LIBRARIES learning_tf
#  CATKIN_DEPENDS roscpp rospy tf turtlesim
#  DEPENDS system_lib

# include

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



Please include your full CMakelists file. Its definitely a problem with your CMakeLists. I would suspect you didnt add the packages to the catkin_package() macro

stevemacenski gravatar image stevemacenski  ( 2019-03-25 14:43:13 -0500 )edit

hello, I have included my CMakeLists inside my posts here. There is a lot of comments generated from auto catkin_create_pkg learning_tf tf roscpp rospy turtlesim

calvintanct gravatar image calvintanct  ( 2019-03-26 06:48:42 -0500 )edit

@calvintanct I've removed the majority of the comments from your CMakeLists.txt file as they're not necessary

jayess gravatar image jayess  ( 2019-03-26 14:45:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-26 14:21:06 -0500

Now that you have the full Cmakelists, I'd put $1 that your issue is here

#  INCLUDE_DIRS include
#  LIBRARIES learning_tf
#  CATKIN_DEPENDS roscpp rospy tf turtlesim
#  DEPENDS system_lib

You should read that snippet above here and try to understand what this is doing. To get you going, you need to uncomment the CATKIN_DEPENDS and probably the INCLUDE_DIRS lines.

edit flag offensive delete link more


Since he is using catkin to build his project, CATKIN_DEPENDS should be uncommented, and all additional ros packages should be listed there as well

Dyson sphere gravatar image Dyson sphere  ( 2019-03-26 19:58:19 -0500 )edit

I believe that is what i said above.

stevemacenski gravatar image stevemacenski  ( 2019-03-26 20:05:22 -0500 )edit

Hello, thank you for the answer, I will update again if it is working or not. I used the same ros package with same package.xml and CMakeLists.txt in different installation Ubuntu 16 and Ros Kinetic, and it is working. However it cannot work in my setup Ubuntu 18 Ros Melodic. It seems a bit weird to me

calvintanct gravatar image calvintanct  ( 2019-03-26 22:07:42 -0500 )edit

Is your error solved @calvintanct .Even after uncomment as mentioned in answer ,I am facing the same error.

charvi gravatar image charvi  ( 2019-06-27 02:05:19 -0500 )edit

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


Asked: 2019-03-25 11:30:47 -0500

Seen: 539 times

Last updated: Mar 26 '19