Skip to content

rclcpp fails to build with MSVC 2022 17.13+ due to breaking MSVC changes #2853

@RangaSundarRS

Description

@RangaSundarRS

Generated by Generative AI

No response

Operating System:

Microsoft Windows [Version 10.0.26100.4061]

ROS version or commit hash:

kilted, commit 1bd4bec

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclcpp

'ros2 doctor --report' output

No response

Steps to reproduce issue

  1. From a clean Windows 11 install, I followed the Kilted source build instructions: https://docs.ros.org/en/kilted/Installation/Alternatives/Windows-Development-Setup.html, but using MSVC 2022 instead.
  2. I have installed VS BuildTools 2022 17.14.0 and MSVC v143 VS 2022 x64/x86 build tools.
  3. I follow the same Kilted build instructions, sourcing the VS 2022 environment instead.
  4. Source the VS BuildTools environment (via vcvarsall.bat) and the pixi environment
  5. colcon build --merge-install
  6. rclcpp fails to build. The key errors are in test_events_queue and test_waitable. In both, error C2039 is encountered: 'chrono_literals': is not a member of 'std'.

Expected behavior

rclcpp and its tests should successfully build.

Actual behavior

The build fails. This is due to a breaking change in Visual Studio (mentioned in https://devblogs.microsoft.com/cppblog/whats-new-for-c-developers-in-visual-studio-2022-17-13/). std::chrono is no longer included in common STL headers, and instead needs to be included from the header.

Adding #include to the header files for test_events_queue and test_waitable allows it to successfully build with MSVC 2022. I do not know if this would prevent it from successfully building with MSVC 2019, or with other compilers / operating systems.

The streams.log from this build is here:

streams.log

Additional information

See https://devblogs.microsoft.com/cppblog/whats-new-for-c-developers-in-visual-studio-2022-17-13/ for information on the header changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions