Skip to content

[BUG] Build fails on Humble when system libcpp-httplib-dev is installed - old cpp-httplib version lacks StatusCode and std::string overloads #225

@bburda

Description

@bburda

Bug report

Steps to reproduce

  1. Install ROS 2 Humble on Ubuntu 22.04 (Jammy)
  2. Install the system cpp-httplib package: sudo apt install libcpp-httplib-dev
  3. Clone ros2_medkit on main and build:
    source /opt/ros/humble/setup.bash
    colcon build --symlink-install

Expected behavior

The build should either succeed or fail early with a clear error message indicating that the system cpp-httplib version is too old.

Actual behavior

ros2_medkit_gateway fails to compile with multiple errors caused by API incompatibilities between the system-installed cpp-httplib (~0.10.x on Jammy) and the version our code expects (0.14+).

3 distinct errors (repeated across every translation unit that includes the affected headers):

  1. httplib::StatusCode has not been declared (handler_context.hpp:242)

    • The httplib::StatusCode enum (e.g. StatusCode::BadRequest_400) was added in cpp-httplib 0.14+. Older versions use plain int.
  2. set_content_provider: const string& vs const char* (http_utils.hpp:192)

    • Old API signature is set_content_provider(size_t, const char*, ...), our code passes const std::string&.
  3. Server::listen: const string& vs const char* (http_server.cpp:70,75)

    • Old API signature is listen(const char*, int), our code passes const std::string&.

Root cause: medkit_find_cpp_httplib() in cmake/ROS2MedkitCompat.cmake uses pkg-config to find cpp-httplib without checking the version. On Humble, if libcpp-httplib-dev is installed via apt, pkg-config finds it and uses the old version. The fallback path (building from source via find_package(httplib REQUIRED)) is never triggered.

Environment

  • ros2_medkit version: main (HEAD)
  • ROS 2 distro: Humble
  • OS: Ubuntu 22.04 (Jammy)
  • cpp-httplib system package version: ~0.10.x (from libcpp-httplib-dev apt package)

Additional information

Proposed fix: Add a minimum version check in medkit_find_cpp_httplib() so that pkg-config rejects old versions and falls back to the cmake/source path:

pkg_check_modules(cpp_httplib IMPORTED_TARGET cpp-httplib>=0.14)

Workaround: Uninstall the system package (sudo apt remove libcpp-httplib-dev) and build cpp-httplib >= 0.14 from source so find_package(httplib) picks it up instead.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions