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

How to compile ros application manually by g++ and form object or library files

asked 2015-01-27 22:16:37 -0500

m_ramshad gravatar image

Hi, I have been working on a project where I use ROS to create a c++ publisher and subscriber application. Publisher is running on my machine and the subscriber running on another remote machine connected through Wi-Fi. I use single master uri for both. Everything works fine.

Now I need to include my publisher program as library to another my c++ program, I know how to create headers and include them in another program for normal c++ applications. But i don't know how to make a library file (as I understood it should compiled as static library) from my ros package.?

I am using ros indigo, Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-01-28 01:57:16 -0500

BennyRe gravatar image

You don't have to compile it by hand. Catkin can compile libraries too.

The command you need is add_library(). Have a look at the CMakeLists.txt documentation section 7.5.

The library then gets put in den lib folder of your devel space.

edit flag offensive delete link more


Thanks Benny, I was able to produce .so library file and i am now trying to include it in my program I have a small clarification, do you think it is possible for me to compile and run my c++ program just by including the above mentioned .so file while that .so program have many dependencs in ros

m_ramshad gravatar image m_ramshad  ( 2015-01-28 03:09:13 -0500 )edit

If you use ROS functions in your library it will not work without the ROS dependencies. You could use the recommended ROS design and put all your logic an a ROS-independent library and use this library in your ROS node.

BennyRe gravatar image BennyRe  ( 2015-01-28 06:24:09 -0500 )edit

Question Tools

1 follower


Asked: 2015-01-27 22:16:37 -0500

Seen: 737 times

Last updated: Jan 28 '15