unable to compile a simple publisher node
when i tried to compile a simple node of publish, it give me following error
chhonkar@CHHONKAR:~/Desktop/beginner_tutorials/src$ g++ hellop.cpp -o hellop -I/opt/ros/indigo/include -L/opt/ros/indigo/lib -Wl,-rpath,/opt/ros/indigo/lib -lroscpp -lrosconsole -lrostime
error :
/usr/bin/ld: /tmp/ccBLS7zj.o: undefined reference to symbol '_ZN3ros13serialization18throwStreamOverrunEv'
/opt/ros/indigo/lib/libroscpp_serialization.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
my code written in cpp is as follow :
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sstream"
using namespace ros;
int main (int argc, char**argv)
{
init (argc,argv, "hellop");
NodeHandle n;
start();
Publisher chatter_pub = n.advertise<std_msgs::String>("chatter",1000);
Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
std_msgs::String msg;
std::stringstream ss;
ss<<"hello oye londe"<<count;
msg.data = ss.str();
ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg);
spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
you should really be using cmake to compile your nodes, as described in the tutorials.