Fixing Formatting Errors when building Ouster ROS driver on Ubuntu 18.04 with ROS1 Melodic
Overview
This document addresses a build error encountered when compiling the Ouster ROS driver on Ubuntu 18.04 using ROS1 Melodic. The error relates to an incompatibility between fmtlib and the spdlog logging macro warn() when formatting std::string types.
Error Message
/home/xxx/xxx/xxx_ws/src/ouster-ros/ouster-sdk/ouster_client/src/curl_client.h:95:43: error: no matching function for call to ‘spdlog::logger::warn(std::_cxx11::basic_string<char>, const string&, long int&, std::_cxx11::string&)’url, http_code, buffer);Root Cause
This issue is caused by older versions of fmtlib and spdlog, commonly bundled with Ubuntu 18.04. They do not support passing std::string directly to formatting macros like warn().
Recommended Fix
Instead of concatenating or passing a std::string to warn(), use format placeholders directly in the macro string.
Code (Line 95 in curl_client.h):
ouster::sensor::logger().warn(
std::string("Re-attempting CurlClient::execute_get after "
"failure for url: ") +
"{} with the code: [{}] - and return: {}",
url, http_code, buffer);Suggestion to change the code to:
ouster::sensor::logger().warn(
"Re-attempting CurlClient::execute_get after failure for url: [{}] with the code: [{}] - and return: {}",
url, http_code, buffer);Recommended Build Environment
To avoid further issues:
Use Ubuntu 18.04 with updated dev packages:
sudo apt install -y \
build-essential \
libeigen3-dev \
libjsoncpp-dev \
libspdlog-dev \
libcurl4-openssl-dev \
cmakeAdditional Resources
Blog article showing similar issue when building Ouster ROS driver in Ubuntu 18.04 and ROS Melodic: CSDN Article
Appendix: Alternate Debug Steps
If rebuild fails again:
Locate
curl_client.hinouster_client/srcGo to line 95
Apply the fixed formatting line