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

unable to compile a simple publisher node

asked 2014-09-23 00:11:05 -0500

ASHISH CHHONKAR gravatar image

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;

}

edit retag flag offensive close merge delete

Comments

2

you should really be using cmake to compile your nodes, as described in the tutorials.

ahendrix gravatar image ahendrix  ( 2014-09-23 00:44:16 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-09-23 03:07:02 -0500

bvbdort gravatar image

Link libroscpp_serialization.so in your build command but not sure of compilation if any other libraries are missing.

Correct way would be to create a ROS package CreatingPackage make things easy and add your source and update CMakeLists.txt and then build with catkin_make.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-09-23 00:11:05 -0500

Seen: 1,778 times

Last updated: Sep 23 '14