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

How do I build a package as a library in catkin?

asked 2014-05-09 14:20:41 -0500

blakeh gravatar image

updated 2014-05-09 14:21:44 -0500

I'm trying to build a c++ package as a library so that other packages can link to it. I've been working off the page http://docs.ros.org/api/catkin/html/howto/building_executables.html but no luck. It seems gcc is not getting the -PIC -shared flags etc.

catkin_make is giving me "undefined reference to `main'" and also is failing to link to basic ros classes even though roscpp is specified in all the usual places.

All worked well when the cpp and .h files were in the same package as an another cpp file which called classes in the file I want to make a library. Can I separate the .cpp files into separate packages and make the one without main() a library?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-09 15:51:25 -0500

joq gravatar image

Since you want to build a library, that is the wrong how-to page.

Try this one: http://docs.ros.org/api/catkin/html/h...

edit flag offensive delete link more

Comments

If that is not enough detail to fix your problem, please edit your question and add the relevant parts of your CMakeLists.txt.

joq gravatar image joq  ( 2014-05-10 04:28:19 -0500 )edit

Right - yes I was using your link but posted the wrong one. I'll have to wait until Monday to post the CMakeLists.txt file --- thanks.

blakeh gravatar image blakeh  ( 2014-05-10 06:55:40 -0500 )edit

Thank you - on further checking CMakeList.txt and matching it carefully to the link in your answer, it seems to work now!

blakeh gravatar image blakeh  ( 2014-05-13 07:56:25 -0500 )edit

If this answer works for you, please click on the green check mark, so others will know this question has been resolved.

joq gravatar image joq  ( 2014-05-13 09:07:30 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2014-05-09 14:20:41 -0500

Seen: 364 times

Last updated: May 09 '14