make构建输出中'required from'信息的含义与作用咨询
编译错误中
required from行的含义解析及问题修复 问题背景
我尝试从GitHub的gr-sidekiq项目构建代码,执行make命令时,输出中出现多条以required from开头的内容,其含义不明。现咨询:这些行是每次出现都代表错误?还是用于解释最终错误发生原因的调用追踪?抑或仅为告知性信息,若为后者具体传达什么内容?
本次编译输出日志:
(radioconda) me@memfish1:~/Projects/gr-sidekiq/build$ make Scanning dependencies of target gnuradio-sidekiq [ 10%] Building CXX object lib/CMakeFiles/gnuradio-sidekiq.dir/sidekiq_tx_impl.cc.o In file included from /home/me/anaconda3/envs/radioconda/include/spdlog/fmt/fmt.h:31, from /home/me/anaconda3/envs/radioconda/include/spdlog/common.h:45, from /home/me/anaconda3/envs/radioconda/include/gnuradio/logger.h:36, from /home/me/anaconda3/envs/radioconda/include/gnuradio/custom_lock.h:15, from /home/me/anaconda3/envs/radioconda/include/gnuradio/buffer.h:15, from /home/me/anaconda3/envs/radioconda/include/gnuradio/buffer_double_mapped.h:15, from /home/me/anaconda3/envs/radioconda/include/gnuradio/io_signature.h:23, from /home/me/Projects/gr-sidekiq/lib/sidekiq_tx_impl.cc:7: /home/me/anaconda3/envs/radioconda/include/fmt/core.h: In instantiation of ‘constexpr fmt::v9::detail::value<Context> fmt::v9::detail::make_value(T&&) [with Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; T = const std::shared_ptr<pmt::pmt_base>&]’: /home/me/anaconda3/envs/radioconda/include/fmt/core.h:1777:29: required from ‘constexpr fmt::v9::detail::value<Context> fmt::v9::detail::make_arg(T&&) [with bool IS_PACKED = true; Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; fmt::v9::detail::type <anonymous> = fmt::v9::detail::type::custom_type; T = const std::shared_ptr<pmt::pmt_base>&; typename std::enable_if<IS_PACKED, int>::type <anonymous> = 0]’ /home/me/anaconda3/envs/radioconda/include/fmt/core.h:1901:77: required from ‘constexpr fmt::v9::format_arg_store<Context, Args>::format_arg_store(T&& ...) [with T = {const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&}; Context = fmt::v9::basic_format_context<fmt::v9::appender, char>; Args = {std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>}]’ /home/me/anaconda3/envs/radioconda/include/spdlog/logger.h:381:5: required from ‘void spdlog::logger::log_(spdlog::source_loc, spdlog::level::level_enum, spdlog::string_view_t, Args&& ...) [with Args = {const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&}; spdlog::string_view_t = fmt::v9::basic_string_view<char>]’ /home/me/anaconda3/envs/radioconda/include/spdlog/logger.h:90:9: required from ‘void spdlog::logger::log(spdlog::source_loc, spdlog::level::level_enum, fmt::v9::format_string<T ...>, Args&& ...) [with Args = {const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&}; fmt::v9::format_string<T ...> = fmt::v9::basic_format_string<char, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&>]’ /home/me/anaconda3/envs/radioconda/include/spdlog/logger.h:96:9: required from ‘void spdlog::logger::log(spdlog::level::level_enum, fmt::v9::format_string<T ...>, Args&& ...) [with Args = {const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&}; fmt::v9::format_string<T ...> = fmt::v9::basic_format_string<char, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&>]’ /home/me/anaconda3/envs/radioconda/include/spdlog/logger.h:152:9: required from ‘void spdlog::logger::debug(fmt::v9::format_string<T ...>, Args&& ...) [with Args = {const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&}; fmt::v9::format_string<T ...> = fmt::v9::basic_format_string<char, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&, const std::shared_ptr<pmt::pmt_base>&>]’ /home/me/anaconda3/envs/radioconda/include/gnuradio/logger.h:166:9: required from ‘void gr::logger::debug(const string_view_t&, const Args& ...) [with Args = {std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>, std::shared_ptr<pmt::pmt_base>}; spdlog::string_view_t = fmt::v9::basic_string_view<char>]’ /home/me/Projects/gr-sidekiq/lib/sidekiq_tx_impl.cc:348:26: required from here /home/me/anaconda3/envs/radioconda/include/spdlog/logger.h:374:75: in ‘constexpr’ expansion of ‘fmt::v9::make_format_args<>(std::forward<const std::shared_ptr<pmt::pmt_base>&>(args#0), std::forward<const std::shared_ptr<pmt::pmt_base>&>(args#1), std::forward<const std::shared_ptr<pmt::pmt_base>&>(args#2))’ /home/me/anaconda3/envs/radioconda/include/fmt/core.h:1757:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt 1757 | formattable, | ^~~~~~~~~~~ make[2]: *** [lib/CMakeFiles/gnuradio-sidekiq.dir/build.make:63: lib/CMakeFiles/gnuradio-sidekiq.dir/sidekiq_tx_impl.cc.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:269: lib/CMakeFiles/gnuradio-sidekiq.dir/all] Error 2 make: *** [Makefile:141: all] Error 2
核心问题解答
required from行的本质:这些行不是错误本身,是C++编译器生成的调用栈追踪信息,用来定位错误的根源。- 具体作用:它会反向梳理代码的调用链路——从触发错误的底层函数/模板,一步步回溯到你项目中实际编写的代码位置。比如本次日志里最后一行
required from here指向sidekiq_tx_impl.cc:348,就是你代码里真正触发问题的地方。 - 出现场景:只有当编译出现错误时才会生成这类信息,它是编译器帮你缩小排查范围的辅助工具,本身不是错误。
本次编译错误的具体分析
最终触发编译失败的错误是:
error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization
意思是:你在代码里用日志库(spdlog,依赖fmt库)输出std::shared_ptr<pmt::pmt_base>类型的变量,但fmt库没有为这个类型定义格式化规则——简单说就是日志不知道怎么把这个类型转成字符串输出。
结合调用追踪可以确定:错误触发于sidekiq_tx_impl.cc第348行的debug日志调用,那里传入了pmt类型的智能指针,而当前radioconda环境中的fmt/gnuradio版本没有为该类型提供格式化支持。
修复建议
- 若不需要输出该变量,直接从日志调用中删除对应的参数;
- 若需要输出,手动将pmt类型转换为字符串,比如调用gnuradio pmt库的字符串转换函数(如
pmt::to_string())后再传给日志函数; - 检查gr-sidekiq项目是否有适配当前radioconda环境的补丁,这可能是版本兼容性问题导致的。
内容的提问来源于stack exchange,提问作者user1245262
相关产品推荐
相关产品推荐

