You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在OpenSUSE上集成Drake:spdlog与fmt编译错误(续)

在OpenSUSE上集成Drake时遇到fmt库write<char>函数调用歧义的编译错误

我正在OpenSUSE上集成Drake,代码托管在个人仓库中。这是之前相关问题的续篇,目前进入新的阶段。

我按照建议使用OpenSUSE官方提供的spdlog和fmt预编译包,编写了对应的Dockerfile,通过zypper安装了spdlog-devel(版本1.9.2-bp154.1.41)及自动附带的fmt-devel(版本8.0.1-150400.1.8),并确认了文件路径。随后修改cmake命令为:

cmake .. -DWITH_USER_FMT:BOOLEAN=ON -DWITH_USER_SPDLOG:BOOLEAN=ON -Dfmt_DIR="/usr/lib64/cmake/fmt" -Dspdlog_DIR="/usr/lib64/cmake/spdlog"

执行make install时触发编译错误,核心问题是fmt库中write<char>函数调用出现歧义,具体错误日志如下:

dan@169dafd51f9a:~/drake/cmake> make install
INFO: Analyzed target //:install (324 packages loaded, 26689 targets configured).
INFO: Found 1 target...
ERROR: /home/dan/drake/common/symbolic/expression/BUILD.bazel:19:17: Compiling common/symbolic/expression/formula_cell.cc failed: (Exit 1): gcc-10 failed: error executing command (from target //common/symbolic/expression:_everything_compiled_cc_impl) /usr/bin/gcc-10 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 88 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from bazel-out/k8-opt/bin/common/_virtual_includes/fmt/drake/common/fmt.h:6,
                 from bazel-out/k8-opt/bin/common/_virtual_includes/copyable_unique_ptr/drake/common/copyable_unique_ptr.h:18,
                 from bazel-out/k8-opt/bin/common/_virtual_includes/_random_headers_cc_impl/drake/common/random.h:8,
                 from bazel-out/k8-opt/bin/common/symbolic/expression/_virtual_includes/_everything_compiled_cc_impl/drake/common/symbolic/expression/formula_cell.h:17,
                 from common/symbolic/expression/formula_cell.cc:2:
external/fmt/include/fmt/format.h: In instantiation of 'std::string fmt::v8::to_string(const T&) [with T = drake::symbolic::Expression; typename std::enable_if<(! std::is_integral<_Tp>::value), int>::type <anonymous> = 0; std::string = std::__cxx11::basic_string<char>]':
bazel-out/k8-opt/bin/common/_virtual_includes/fmt/drake/common/fmt_eigen.h:80:38:   required from 'fmt::v8::formatter<drake::internal::fmt_eigen_ref<Derived> >::format<fmt::v8::basic_format_context<fmt::v8::appender, char> >::<lambda(const auto:19&)> [with auto:19 = drake::symbolic::Expression; std::string = std::__cxx11::basic_string<char>]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/CoreEvaluators.h:583:22:   required from 'Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::CoeffReturnType Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::coeff(Eigen::Index, Eigen::Index) const [with UnaryOp = fmt::v8::formatter<drake::internal::fmt_eigen_ref<Derived> >::format<fmt::v8::basic_format_context<fmt::v8::appender, char> >::<lambda(const auto:19&)>; ArgType = const Eigen::Ref<const Eigen::Matrix<drake::symbolic::Expression, -1, -1, 0, -1, -1> >; typename Eigen::CwiseUnaryOp<UnaryOp, ArgType>::Scalar = std::__cxx11::basic_string<char>; Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<UnaryOp, ArgType>, Eigen::internal::IndexBased>::CoeffReturnType = const std::__cxx11::basic_string<char>; Eigen::Index = long int]'
external/fmt/include/fmt/format.h:2602:22: error: call of overloaded 'write<char>(std::back_insert_iterator<std::__cxx11::basic_string<char> >, const drake::symbolic::Expression&)' is ambiguous
 2602 |   detail::write<char>(std::back_inserter(result), value);
      |   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/fmt/include/fmt/format.h:1819:6: note: candidate: 'OutputIt fmt::v8::detail::write(OutputIt, T) [with Char = char; OutputIt = std::back_insert_iterator<std::__cxx11::basic_string<char> >; T = drake::symbolic::Expression; typename std::enable_if<std::integral_constant<bool, (std::numeric_limits<_UIntType>::is_iec559 && (sizeof (T) <= sizeof (double)))>::value, int>::type <anonymous> = 0]'
 1819 | auto write(OutputIt out, T value) -> OutputIt {
      |      ^~~~~
external/fmt/include/fmt/format.h:1944:20: note: candidate: 'constexpr typename std::enable_if<(fmt::v8::detail::type_constant<decltype (fmt::v8::detail::arg_mapper<fmt::v8::basic_format_context<OutputIt, Char> >().map(declval<const T&>())), typename fmt::v8::basic_format_context<OutputIt, Char>::char_type>::value == fmt::v8::detail::type::custom_type), OutputIt>::type fmt::v8::detail::write(OutputIt, const T&) [with Char = char; OutputIt = std::back_insert_iterator<std::__cxx11::basic_string<char> >; T = drake::symbolic::Expression; typename std::enable_if<(fmt::v8::detail::type_constant<decltype (fmt::v8::detail::arg_mapper<fmt::v8::basic_format_context<OutputIt, Char> >().map(declval<const T&>())), typename fmt::v8::basic_format_context<OutputIt, Char>::char_type>::value == fmt::v8::detail::type::custom_type), OutputIt>::type = std::back_insert_iterator<std::__cxx11::basic_string<char> >]'
 1944 | FMT_CONSTEXPR auto write(OutputIt out, const T& value) ->
      |                    ^~~~~
Target //:install failed to build
...
make: *** [Makefile:146: all] Error 2

现寻求解决此编译歧义错误的方案。


内容的提问来源于Stack Exchange,提问作者Daniel He

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 18:15:53