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

Ubuntu 20.04.1 LTS下编译PDDL 2.1时序规划器POPF失败求助

编译POPF规划器时遇到std::iterator_traits相关编译错误的解决方案

问题背景

  • 系统环境:Ubuntu 20.04.1 LTS
  • 操作流程:按指南执行以下命令编译支持PDDL durative-actions的POPF规划器:
    mkdir build
    cd build
    cmake path_to_src_folder
    make
    
  • 编译错误:

    /home/virginia/Scaricati/popf/src/VALfiles/TimSupport.cpp:1392:36: required from here
    /usr/include/c++/9/bits/stl_tree.h:1117:16: error: no type named ‘value_type’ in ‘struct std::iterator_traits<TIM::getConditionally<std::_Rb_tree_const_iteratorTIM::Property* > >’
    1117 | __enable_if_t<!__same_value_type<_InputIterator>::value>
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    make[2]: *** [src/VALfiles/CMakeFiles/Inst.dir/build.make:154: src/VALfiles/CMakeFiles/Inst.dir/TimSupport.o] Errore 1
    make[1]: *** [CMakeFiles/Makefile2:213: src/VALfiles/CMakeFiles/Inst.dir/all] Errore 2

  • 预期结果:生成build/popf/popf-clp二进制文件,未成功。

解决方案

方案1:修改代码补充迭代器关联类型

这个错误是因为TIM::getConditionally迭代器适配器没有正确暴露C++标准库要求的迭代器关联类型,导致std::iterator_traits无法识别它的value_type。

  1. 打开src/VALfiles/TimSupport.cpp文件,找到TIM::getConditionally的定义(通常在错误触发位置附近)。
  2. 给这个结构体添加必要的typedef来暴露迭代器关联类型:
    template <typename Iter>
    struct getConditionally {
        // 添加以下typedef,匹配底层迭代器的类型
        typedef typename Iter::value_type value_type;
        typedef typename Iter::difference_type difference_type;
        typedef typename Iter::pointer pointer;
        typedef typename Iter::reference reference;
        typedef typename Iter::iterator_category iterator_category;
    
        // 保留原有成员变量和方法
        Iter current;
        Iter end;
        // ... 其他原有代码
    };
    
  3. 保存文件后,重新执行make命令编译。

方案2:降级编译器到GCC 8

Ubuntu 20.04默认的GCC 9对C++迭代器的兼容性检查更严格,而POPF的旧代码可能是针对更早版本的GCC编写的。可以切换到GCC 8来编译:

  1. 安装GCC 8:
    sudo apt update && sudo apt install gcc-8 g++-8
    
  2. 进入build目录,清空原有编译缓存并重新配置CMake:
    cd build
    rm -rf ./*
    cmake path_to_src_folder -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
    
  3. 重新执行make编译。

内容的提问来源于stack exchange,提问作者twistedshell

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 13:45:46