视觉SLAM十四讲 报错 error: ‘index_sequence’ is not a member of ‘std‘

视觉SLAM十四讲 报错 error: ‘index_sequence’ is not a member of 'std'

1. 报错

在编译高博的视觉SLAM第7讲的ch7/pose_estimation_3d2d.cpp时,出现错误:

/usr/local/include/g2o/core/base_fixed_sized_edge.h:192:32: error: ‘index_sequence’ is not a member of ‘std’
   struct HessianTupleType<std::index_sequence<Ints...>> {
                                ^~~~~~~~~~~~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.h:192:32: error: ‘index_sequence’ is not a member of ‘std’
/usr/local/include/g2o/core/base_fixed_sized_edge.h:192:51: error: expected parameter pack before ‘...’

2. 原因

视觉SLAM书上的程序使用的g2o版本比较旧了,使用的是c++11版本的g20。而自己在编译g2o的时候编译的是最新版本的g2o,里面大量使用了c++14标准库的一些新特性,比如std::index_sequence等等。而书上的CMakeLists.txt默认使用的是c++11进行cmake编译,所以报错。

3. 解决方案

让CMake编译在C++14标准下进行,在CMakeLists.txt添加:

set(CMAKE_CXX_STANDARD 14)

另外安装了最新的g2o进行编译可能还会出现fmt::v8的链接错误:

CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `fmt::v8::appender fmt::v8::detail::write<char, fmt::v8::appender>(fmt::v8::appender, fmt::v8::basic_string_view<fmt::v8::type_i
dentity<char>::type>, fmt::v8::basic_format_specs<char> const&, fmt::v8::detail::locale_ref) [clone .isra.1451]':                                                                                           
pose_estimation_3d2d.cpp:(.text+0x490c): undefined reference to `fmt::v8::detail::throw_format_error(char const*)'                                                                                          
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: In function `unsigned long long fmt::v8::detail::width_checker<fmt::v8::detail::error_handler>::operator()<float, 0>(float) [clone .isra.384
]':                                                                                  

相应的解决方案在这里。其实就是编译fmt的相关库并且链接到可执行程序上。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值