catkin_make error when I follow wiki/Tutorials/WritingPublisherSubscriber
when I follow wiki Tutorials/WritingPublisherSubscriber(as follow): http://wiki.ros.org/cn/ROS/Tutorials/...
when I do "catkin_make" command in catkin_workspace , there happens some error (following:):
talker.cpp:(.text+0x56): **undefined reference** to `ros::init(int&, char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
.....all the call from ros/ros.h are undefined. why ? how to solve this problem ?
I have added "target_link_libraries(listener ${catkin_LIBRARIES})"
include "ros/ros.h"
include "std_msgs/String.h"
include <sstream>
int main(int argc, char **argv){
ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok()){
std_msgs::String msg; std::stringstream ss; ss << "hello world " << count; msg.data = ss.str(); ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg); ros::spinOnce(); loop_rate.sleep(); ++count;
}
return 0;
}
who can help me to solve this problem?
Can you post your cpp file as well as your cmake file?
@just_go: please don't use answers to post updates to your questions. Edit your original question for that. I've updated your question with the contents of the answer you posted.