系统版本
ubuntu20.04 ros1 noetic 测试日期:2025.11.24
# 改动1
sudo apt install ros-noetic-uuid-msgs
sudo apt install ros-noetic-unique-id
sudo apt-get install ros-noetic-tf2-geometry-msgs
# 改动1结束
# 考虑如下的操作:
# 1. 更新 rosdep 数据库
sudo rosdep init # 如果还没初始化过
rosdep update
# 2. 进入你的工作空间根目录
cd ~/catkin_lanelet2_ws
# 3. 安装所有依赖(包括 build、exec、test 依赖)
rosdep install --from-paths src --ignore-src -r -y
# 改动2
# 编译问题
In file included from /usr/include/boost/config.hpp:61:0,
from /usr/include/boost/math/tools/config.hpp:13,
from /usr/include/boost/math/special_functions/round.hpp:13,
from /opt/ros/kinetic/include/ros/time.h:58,
from /opt/ros/kinetic/include/ros/ros.h:38,
from /home/seivl/hd_ws/src/ad_with_lanelet2/planning/mission_planning/mission_planner/include/mission_planner/lanelet2_impl/mission_planner_lanelet2.h:21,
from /home/seivl/hd_ws/src/ad_with_lanelet2/planning/mission_planning/mission_planner/src/mission_planner_lanelet2/mission_planner_lanelet2.cpp:17:
/usr/include/boost/math/constants/constants.hpp: In static member function ‘static constexpr T boost::math::constants::detail::constant_half<T>::get(const mpl_::int_<5>&)’:
/usr/include/boost/math/constants/constants.hpp:277:3: error: unable to find numeric literal operator ‘operator""Q’
BOOST_DEFINE_MATH_CONSTANT(half, 5.000000000000000000000000000000000000e-01, "5.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e-01")
^
/usr/include/boost/math/constants/constants.hpp:277:3: note: use -std=gnu++11 or -fext-numeric-literals to enable more built-in suffixes
/usr/include/boost/math/constants/constants.hpp: In static member function ‘static constexpr T boost::math::constants::detail::constant_third<T>::get(const mpl_::int_<5>&)’:
/usr/include/boost/math/constants/constants.hpp:278:3: error: unable to find numeric literal operator ‘operator""Q’
BOOST_DEFINE_MATH_CONSTANT(third, 3.333333333333333333333333333333333333e-01, "3.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333e-01")
^
# 解决方案:
修改这些路径下的CMakeLists.txt 文件:
ad_with_lanelet2/map/lanelet2_extension
ad_with_lanelet2/planning/mission_planning/mission_planner
ad_with_lanelet2/map/util/lanelet2_map_preprocessor
ad_with_lanelet2/map/map_tf_generator
# 加入:
add_compile_options(-std=c++14)
#add_compile_options(-std=c++11)
#add_compile_options(-std=gnu++11)
add_compile_options(-fext-numeric-literals)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_MATH_DISABLE_FLOAT128")
# 原文链接:https://blog.youkuaiyun.com/TengYun_zhang/article/details/131452845
# 改动2结束
# 改动3
把下面这段 **直接替换** 原文件
`~/catkin_lanelet2_ws/src/ad_with_lanelet2/lanelet2_examples/src/04_reading_and_writing/main.cpp`
里 **从 `namespace example {` 到 `} // namespace example` 的部分** 即可,其余代码保持不动。
错误核心一句话:
> `lanelet::io_handlers::Configuration` 这个类型**不存在**,系统里真正的名字是
> `std::map<std::string, lanelet::Attribute>`。
---
### ✅ 立即修复(保持系统 lanelet2 不变)
把 `FakeWriter::write` 第 4 个参数改成系统头文件里真实的类型:
```cpp
namespace example {
class FakeWriter : public lanelet::io_handlers::Writer {
public:
using Writer::Writer;
// 注意:Configuration 其实就是 map<string, Attribute>
void write(const std::string& /*filename*/,
const lanelet::LaneletMap& /*laneletMap*/,
lanelet::ErrorMessages& /*errors*/,
const std::map<std::string, lanelet::Attribute>& /*config*/) const override {
// this writer does just nothing
}
static constexpr const char* extension() { return ".fake"; }
static constexpr const char* name() { return "fake_writer"; }
};
} // namespace example
```
---
### 🔧 一键替换
```bash
sed -i 's|lanelet::io_handlers::Configuration|std::map<std::string, lanelet::Attribute>|g' \
~/catkin_lanelet2_ws/src/ad_with_lanelet2/lanelet2_examples/src/04_reading_and_writing/main.cpp
```
---
### ✅ 再编
```bash
catkin build lanelet2_examples
```
---
### 🎯 一句话总结
> **把 `Configuration` 换成 `std::map<std::string, lanelet::Attribute>`**,签名瞬间对上系统头文件,编译秒过。
即可通过编译,**系统 lanelet2 版本、任何其他代码均无需改动**。
# 使用参考资料
https://blog.youkuaiyun.com/hjk_1223/article/details/125708035?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-5-125708035-blog-112923613.235^v43^pc_blog_bottom_relevance_base5&spm=1001.2101.3001.4242.4&utm_relevant_index=8
https://blog.youkuaiyun.com/weixin_55366265/article/details/122205190?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-2-122205190-null-null.pc_agg_new_rank&utm_term=java%E8%A7%A3%E6%9E%90%E9%AB%98%E7%B2%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE&spm=1000.2123.3001.4430
1755

被折叠的 条评论
为什么被折叠?



