cartographer-project / cartographer

Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations.
Apache License 2.0
7.04k stars 2.24k forks source link

Build a docker image with Dockerfile.trusty.bazel occurs an error #1852

Open kulikser opened 2 years ago

kulikser commented 2 years ago

Hi, I tried to build a docker image with Dockerfile.trusty.bazel. Build failed with an error:

ERROR: /cartographer/bazel/repositories.bzl:302:9: //external:com_google_protobuf: no such attribute 'repo_mapping' in 'repo_rule' rule
ERROR: error loading package '': Encountered error while reading extension file 'boost/boost.bzl': no such package '@com_github_nelhage_rules_boost//': error loading package 'external': Could not load //external package
ERROR: error loading package '': Encountered error while reading extension file 'boost/boost.bzl': no such package '@com_github_nelhage_rules_boost//': error loading package 'external': Could not load //external package

If I change bazel version in scripts/install_debs_bazel.sh to the latest release 4.2.1, bazel starts to compile. But if I don't choose toolchain by docker args, bazel uses gcc-4.8.4 as default in trusty, so another error occurs:

cartographer/mapping/internal/imu_based_pose_extrapolator.cc: In static member function 'static std::unique_ptr<cartographer::mapping::PoseExtrapolatorInterface> cartographer::mapping::ImuBasedPoseExtrapolator::InitializeWithImu(const cartographer::mapping::proto::ImuBasedPoseExtrapolatorOptions&, const std::vector<cartographer::sensor::ImuData>&, const std::vector<cartographer::transform::TimestampedTransform>&)':
cartographer/mapping/internal/imu_based_pose_extrapolator.cc:70:10: error: cannot bind 'std::unique_ptr<cartographer::mapping::ImuBasedPoseExtrapolator, std::default_delete<cartographer::mapping::ImuBasedPoseExtrapolator> >' lvalue to 'std::unique_ptr<cartographer::mapping::ImuBasedPoseExtrapolator, std::default_delete<cartographer::mapping::ImuBasedPoseExtrapolator> >&&'
   return extrapolator;

Ubuntu 14.04 has reached end of standard support. And gcc-4 is too old, since gcc-5.1 there are no errors. But this code masks calling of the move constructor. It looks like a typical copy elision case, but it is not. Because auto extrapolator variable has "pointer to derived class" type, but the function returns "pointer to base class" type. Explicitly adding std::move to return makes it easier to understand this problem during future refactoring and solves the problem with gcc-4.8.4.