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

Cant build the example C++ talker

asked 2021-09-17 04:57:29 -0500

Bender_From_Futurama gravatar image

updated 2021-09-17 04:58:02 -0500

I cant figure out why I cant build the example C++ basic talker node.

The talker node.cpp is exactly copied from the wiki and pasted in src/

This is my cmake file.

cmake_minimum_required(VERSION 3.0.2)
project(test_project)
find_package(catkin REQUIRED COMPONENTS 
roscpp
rospy
std_msgs
)

catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS})

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

When I use catkin build test_project I get this error and it continues with undefined reference for everything.

/usr/bin/ld: CMakeFiles/talker.dir/src/talker.cpp.o: in function `main':
talker.cpp:(.text+0x95): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
edit retag flag offensive close merge delete

Comments

Please mention the environment details like ROS, OS version, etc.

SurajJadhav gravatar image SurajJadhav  ( 2021-09-17 06:39:33 -0500 )edit

I have tried generating the same error with the same content of your CMakeLists.txt, it is working fine for me. Can you share complete screenshot of the error log and the command you are using for building.

SurajJadhav gravatar image SurajJadhav  ( 2021-09-17 07:01:28 -0500 )edit

Command for building is catking build <project_name>. The error logs is very similar to this one: https://github.com/pytorch/pytorch/is... </project_name>

Ive been using ROS for a while, so this did not make sense to me. At the end of the day I just reinstalled ROS from scratch and it did the trick

Bender_From_Futurama gravatar image Bender_From_Futurama  ( 2021-09-20 03:06:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-17 06:14:17 -0500

osilva gravatar image

updated 2021-09-17 06:14:47 -0500

I suggest to search for prior answers, this answer may help you: #q81081

edit flag offensive delete link more

Comments

@osilva The user did not say if they are using catkin_make or catkin build.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-17 11:00:23 -0500 )edit

@Mike Scheutzow the user said catkin build

osilva gravatar image osilva  ( 2021-09-17 11:15:37 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-17 04:57:29 -0500

Seen: 76 times

Last updated: Sep 17 '21