0
$\begingroup$

Gazebo Answers logo

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.


Originally posted by David Lu on Gazebo Answers with karma: 111 on 2013-12-28

Post score: 0


Original comments

Comment by scpeters on 2013-12-30:
Are you trying to build sdformat in a catkin workspace or just link to a system install of sdformat?

Comment by David Lu on 2013-12-31:
Specifically, I'm trying to get a package that uses the SDFormat library to build on the ROS build farm.

$\endgroup$

2 Answers 2

1
$\begingroup$

Gazebo Answers logo

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).


Originally posted by scpeters with karma: 2861 on 2013-12-30

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

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:

<build_depend>sdformat</build_depend>
<run_depend>sdformat</run_depend>

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})
target_link_libraries(your_node
                      ${catkin_LIBRARIES}
                      ${SDF_LIBRARIES})

Originally posted by joq with karma: 113 on 2014-01-02

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by scpeters on 2014-01-03:
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.

Comment by joq on 2014-01-03:
Thanks for the correction. Are the SDF_INCLUDE_DIRS and SDF_LIBRARIES variable names I had guessed correct?

Comment by scpeters on 2014-01-06:
Yes, I believe that SDF_INCLUDE_DIRS and SDF_LIBRARIES are correct.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.