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

how to compile .cpp file for ros without main function??

asked 2011-07-26 02:04:44 -0600

SAK gravatar image

updated 2011-09-07 02:53:41 -0600

Hi,

I have created a .cpp file for ros. where i have to put the file and how can i compile it. this file is a standalone file.

edit retag flag offensive close merge delete

Comments

What I know is when you create a package then you can use rosmake to compile.
sam gravatar image sam  ( 2011-07-26 02:51:31 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
3

answered 2011-07-26 03:31:04 -0600

Bemfica gravatar image

updated 2011-07-26 21:32:42 -0600

1.3 Building your nodes
You need to edit you CMakeLists.txt

To build a library take a look at 1.2 Building a library

edit flag offensive delete link more
1

answered 2011-07-26 02:54:24 -0600

SAK gravatar image

updated 2011-07-26 03:10:46 -0600

Thanks for your answer. I got how to compile the single .cpp file without even having no main function.

you have to add two lines to CMakeLists.txt

rosbuild_add_library(gazebo_ros_xx src/gazebo_ros_xx.cpp),

rosbuild_link_boost(gazebo_ros_xx thread)

and then just type the command 'make'.

Hope this will be beneficial to others as well

edit flag offensive delete link more
0

answered 2011-07-26 03:52:50 -0600

SAK gravatar image

the problem with this tutorial is that the the classes contains main function, but in my case they don't have any main function.

The only way i found is answered above.

edit flag offensive delete link more

Comments

please note that in c++ programming you need to have a main function (it is always the first function to be executed). if you are new to c++ there is a good introduction tutorial on www.cplusplus.com (http://www.cplusplus.com/doc/tutorial/)
Bram van de Klundert gravatar image Bram van de Klundert  ( 2011-07-26 18:53:04 -0600 )edit
Thanks for you reply, i have experience with the c++, but i was studying the RaySensor( Sensor for laser ) and there is no main function in the full hierarchy. i think you have an experience with making sensors if i am not wrong...
SAK gravatar image SAK  ( 2011-07-26 19:35:41 -0600 )edit
The only way to have no main (besides some lowlevel stuff) is, when you build a library.
dornhege gravatar image dornhege  ( 2011-07-26 19:49:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2011-07-26 02:04:44 -0600

Seen: 3,373 times

Last updated: Sep 07 '11