I am not able to run a node.
I am running ros kinetic on ubuntu 16.
While running a file hello_world.cpp, I get the following error
/media/ammar/New Volume/December/ros_directory/src/agitr_book/src/hello_world.cpp: line 2: syntax error near unexpected token `('
/media/ammar/New Volume/December/ros_directory/src/agitr_book/src/hello_world.cpp: line 2: `int main (int argc, char **argv)'
This is the code in hello_world.cpp
#include "ros/ros.h"
int main (int argc, char **argv)
{
//intializes ros client library
//last parameter is a string containing
//deafult name of the node
//can be overwridden by a launch file
//call this once at the beginning of the program
ros::init(argc, argv, "hello_ros");
//establishes this program as a ros node
//nh is the main mechanism that the program
//will use to interact with the ROS system
//creating this object registers the program
//as a node at ros master
ros::NodeHandle nh;
//generates an informational message
//send to console screen
ROS_INFO_STREAM("HELLO_ROS");
}
I don't think, there is anything wrong the code as I am following it along with a book. I believe the problem is with the #include line but i don't know what?? If anyone could help me, it will be appreciated.
Since your node is C++, you need to compile it before you run it.