视觉SLAM-安装g2o出现Qt报错error: ‘basic_runtime’ is not a member of ‘fmt’

项目场景:

SLAMBOOK2 ch6 安装g2o ubuntu22.04-fmt8.1.1

问题描述

/usr/include/spdlog/common.h:127:111: error: ‘basic_runtime’ is not a member of ‘fmt’
  127 |           std::is_convertible<T, fmt::basic_string_view<Char>>::value || std::is_same<remove_cvref_t<T>, fmt::basic_runtime<Char>>::value>
      |                                                                                                               ^~~~~~~~~~~~~
/usr/include/spdlog/common.h:127:125: error: template argument 2 is invalid
  127 |           std::is_convertible<T, fmt::basic_string_view<Char>>::value || std::is_same<remove_cvref_t<T>, fmt::basic_runt

原因分析:

这个错误表明在编译时,spdlog(日志库)无法找到 fmt 库的正确定义。basic_runtime 是 fmt 库的一部分,但是 spdlog 无法识别它。

一种可能的解决方法是确保 spdlog 使用的 fmt 版本是兼容的。有时,版本不匹配可能会导致这样的问题。


解决方案:

重新编译安装fmt8.1.1

更改其cmakelist
添加add_compile_options(-fPIC)

project(FMT CXX)
include(GNUInstallDirs)
set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING
            "Installation directory for include files, a relative path that "
            "will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")

# Add -fPIC option
add_compile_options(-fPIC)

option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF)
option(FMT_WERROR "Halt the compilation with an error on compiler warnings."
       OFF)

重新编译

问题解决!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值