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

What is the correct way to add external library?

asked 2012-05-16 21:50:07 -0500

liborw gravatar image

updated 2014-04-20 14:09:20 -0500

ngrennan gravatar image


recently a have problems using external library in ros nodes. I'm using GNU Scientific Library (GSL) in my ros node. So I have to find a way how to add gsl to build and link this node.

First, I found gsl package in ros packages, copied the files, add to ros path, and add depend to the my node manifest, but problem arise see this and this questions.

However, if I understand it correct, which is not necessarily the case, the only important thing of gsl package is that it exports this line in the manifest:

<cpp cflags="-I/usr/include/gsl" lflags="-lgsl -lgslcblas"/>

I can place this include a libraries directly into CMakeList.txt and get rid of gsl package completely see this, the question is if it this is a desired approach?

Finally, I decided to ask more general question as the title states: what is the correct way to include external library (for example gsl) in the ros package?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-05-17 02:24:16 -0500

Lorenz gravatar image

gsl shouldn't be wrapped in a ros package. Instead, your node should use a rosdep dependency on it and the CMake code as in Martin's answer.

Unfortunately, libgsl is not yet in Fuerte's rosdep system. Have a look here for information on how to contribute new rosdep rules.

edit flag offensive delete link more


404 file not found

Akali gravatar image Akali  ( 2015-01-15 19:13:26 -0500 )edit

@Akali, Swearing is not appropriate in our forums. I've edited for comment to remove it.

tfoote gravatar image tfoote  ( 2015-01-15 20:02:35 -0500 )edit

answered 2012-05-16 22:42:45 -0500

I don't know if this would be the best approach, but what I do to include gsl is to add the following to my CMakeList.txt:

find_package( PkgConfig REQUIRED)
pkg_check_modules( gsl REQUIRED gsl )

add_executable( my_exec src/my_source.cpp )
target_link_libraries( my_exec ${gsl_LIBRARIES} )

Hope this helps.

edit flag offensive delete link more


Yeah, it helps, however does not answer the question what is the correct approach, thanks anyway.

liborw gravatar image liborw  ( 2012-05-16 23:00:34 -0500 )edit

This is the first step of the correct approach. The rest involves adding a rosdep to your manifest.xml, and then making sure the rosdep is defined, as explained by @Lorenz.

joq gravatar image joq  ( 2012-05-17 05:56:05 -0500 )edit

Question Tools


Asked: 2012-05-16 21:50:07 -0500

Seen: 3,986 times

Last updated: May 17 '12