Skip to content

[ROS2 Humble] Missing OctoMap linkage in octomap_world causes undefined reference errors when building dsv_planner #11

@JLCucumber

Description

@JLCucumber

Description:

I was installing the Autonomous Exploration Development Environment, where the non-planner validation demo worked well. However, I encounted some problems when I wanted to install this planner.

Environment:

  • Ubuntu 22.04
  • ROS2 Humble
  • GCC/G++ 11.4
  • CMake 3.22
  • Building dsv_planner (depends on octomap_world)

Problem:

When building dsv_planner, linking fails with multiple undefined references to octomap::... and octomath::....
Example error:

/usr/bin/ld: /home/.../liboctomap_world.so: undefined reference to `octomap::Pointcloud::~Pointcloud()'
/usr/bin/ld: /home/.../liboctomap_world.so: undefined reference to `octomap::AbstractOccupancyOcTree::readBinary(...)'
collect2: error: ld returned 1 exit status

Root cause:

The octomap_world library does not link against OctoMap core libraries (liboctomap.so, liboctomath.so).
While ament_target_dependencies(${PROJECT_NAME} octomap ...) is present, it does not add system-level OctoMap libraries to the linker command.


How to reproduce:

  1. Fresh ROS2 Humble setup on Ubuntu 22.04

  2. Install dependencies as listed in the official setup notes:

    sudo apt install ros-humble-octomap-ros libgoogle-glog-dev libgflags-dev
  3. Build dsv_planner:

    colcon build --symlink-install --packages-select dsvplanner
  4. Observe undefined reference errors from liboctomap_world.so.


Proposed fix:

In
src/volumetric_mapping/octomap_world/CMakeLists.txt,
add explicit OctoMap linkage after ament_target_dependencies():

find_package(octomap REQUIRED)

target_link_libraries(${PROJECT_NAME}
  ${PCL_LIBRARIES}
  ${OCTOMAP_LIBRARIES}  # Ensures liboctomap.so and liboctomath.so are linked
)

Verification:

After patching:

ldd install/octomap_world/lib/liboctomap_world.so | grep octomap

Outputs:

liboctomap.so => /usr/lib/x86_64-linux-gnu/liboctomap.so
liboctomath.so => /usr/lib/x86_64-linux-gnu/liboctomath.so

Then, dsv_planner builds successfully, and the exploration demo runs without errors.


Additional notes:

  • Also, liboctomap-dev is required in addition to ros-humble-octomap-ros, but not mentioned in the setup notes.
    It provides liboctomap.so and liboctomath.so.
  • The fix is backward compatible and safe for both ROS2 Humble and Jazzy.

(the mainbody was generated with GPT, so if something unclear pls leave a message)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions