0
$\begingroup$

Rosanswers logo

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?


Originally posted by blakeh on ROS Answers with karma: 17 on 2014-05-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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

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


Originally posted by joq with karma: 25443 on 2014-05-09

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by joq on 2014-05-10:
If that is not enough detail to fix your problem, please edit your question and add the relevant parts of your CMakeLists.txt.

Comment by blakeh on 2014-05-10:
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.

Comment by blakeh on 2014-05-13:
Thank you - on further checking CMakeList.txt and matching it carefully to the link in your answer, it seems to work now!

Comment by joq on 2014-05-13:
If this answer works for you, please click on the green check mark, so others will know this question has been resolved.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.