Home | Tutorials | Wiki | Issues
Ask Your Question

How do I catkin-depend on the SDFormat library?

asked 2013-12-28 09:51:48 -0500

David Lu gravatar image

I have a ROS-hydro catkinized package that depends on SDFormat library, but can't figure out how to get it to link properly to the SDFormat library.

edit retag flag offensive close merge delete


Are you trying to build sdformat in a catkin workspace or just link to a system install of sdformat?

scpeters gravatar imagescpeters ( 2013-12-30 16:29:22 -0500 )edit

Specifically, I'm trying to get a package that uses the SDFormat library to build on the ROS build farm.

David Lu gravatar imageDavid Lu ( 2013-12-31 14:56:49 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-12-30 16:34:44 -0500

scpeters gravatar image

SDFormat is not a catkin package; it is a plain cmake package. Gazebo uses pkg-config to find sdformat and explicitly links against the sdformat libraries where necessary.

If you also want to build sdformat from source in a catkin workspace, you will need to add a package.xml file (see the package_xml branch in sdformat for an example).

edit flag offensive delete link more

answered 2014-01-02 21:25:25 -0500

joq gravatar image

updated 2014-01-03 19:43:39 -0500

Normally, you would add a system dependency on sdformat, which is released with Hydro. Unfortunately, it does not seem to have been defined via rosdep yet. You should probably contribute the missing definition to fix that problem.

Then, in your package.xml, add:


With sdformat installed, in your CMakeLists.txt, find the SDF system library:

find_package(PkgConfig REQUIRED)
pkg_check_modules(SDF sdformat REQUIRED)
include_directories(include ${SDF_INCLUDE_DIRS})

Then your own code will need something like this to build with it:

add_executable(your_node ${YOUR_NODE_SOURCES})
edit flag offensive delete link more



You actually need to search for sdformat: pkg_check_modules(SDF sdformat REQUIRED). It's a quirk of Gazebo's cmake setup; we already had variables with prefix SDF_ spread out, so we search for sdformat, but with variables named SDF. Sorry if that's a confusing example.

scpeters gravatar imagescpeters ( 2014-01-03 17:14:36 -0500 )edit

Thanks for the correction. Are the `SDF_INCLUDE_DIRS` and `SDF_LIBRARIES` variable names I had guessed correct?

joq gravatar imagejoq ( 2014-01-03 19:41:22 -0500 )edit

Yes, I believe that SDF_INCLUDEDIRS and SDFLIBRARIES are correct.

scpeters gravatar imagescpeters ( 2014-01-06 11:28:55 -0500 )edit

answered 2014-01-02 02:56:00 -0500

as addition to scpeters answer:

You can add sdformat as system dependency. You can do so by calling the catkin_create_pkg script with the parameter -s sdformat. This should solve the problem without adding a package.xml.

If you already have a package you can just add sdformat like you would do with gazebo. If you are already linking gazebo as sysdep this should not be necessary...

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2013-12-28 09:51:48 -0500

Seen: 521 times

Last updated: Jan 03 '14