ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
If I see correctly, your Eclipse does not recognize ros libraries. Follow these steps to install the Kepler Eclipse and then do a cmake compilation in order to make it recognisable.
1) http://www.eclipse.org/downloads/ From the eclipse page, scroll down to C/C++ for Developers and download it. Then untar it and copy it into /opt folder.
2) Start eclipse by command
/opt/eclipse/./eclipse
3) If it complaints for java, install openjdk-7-jre.
4) Now go right to your catkin workspace and create a ros package
roscreate-pkg my_pkg_example roscpp
5) Make it eclipse project
cd ~/catkin_ws/src/my_pkg_example/
make eclipse-project
6) Now, go ahead and create the file src/myfile.cpp and edit cmake by adding something like this to the default cmake (Assuming your executable is in src directory)
rosbuild_add_executable(my_pkg_example src/myfile.cpp)
7) On the terminal type
cd ~/catkin_ws/src/my_pkg_example/
cmake .
make
8) The last thing to do now is to go to Eclipse and Project > Run & Debug Settings (or something like this I don't remember). Add C/C++ Application. Select binary file which is ~/catkin_ws/src/my_pkg_example/bin/my_pkg_example. Then hit Apply.
Now your file should be correct.