Cant build the example C++ talker
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)'
Please mention the environment details like ROS, OS version, etc.
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.
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