【问题标题】:error boost::filesystem has no member named string()错误 boost::filesystem 没有名为 string() 的成员
【发布时间】:2015-11-17 02:16:57
【问题描述】:

我正在尝试在我的机器 (Ubuntu 12.04 LTS) 和集群系统上的节点 (CentOS) 上为使用 boost 的项目构建可执行文件。我设法在两台机器上从源代码安装了 boost。当我运行make 命令时,我能够在我的机器上为我的项目获取可执行文件,但在节点上不是。在集群节点上,它说:

source/MainCompressor.cpp: In member function ‘void MainCompressor::compress(std::__cxx11::string, std::__cxx11::string)’:
source/MainCompressor.cpp:76:80: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         boost::filesystem::copy_file(reference, outpath + reference.filename().string());
                                                                                ^
source/MainCompressor.cpp:93:49: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
     compList << outpath << reference.filename().string() << endl;
                                                 ^
source/MainCompressor.cpp:99:47: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         string filename = filepath.filename().string();
                                               ^
source/MainCompressor.cpp: In member function ‘void MainCompressor::decompress(std::__cxx11::string, std::__cxx11::string)’:
source/MainCompressor.cpp:171:47: error: ‘boost::filesystem::basic_path<std::__cxx11::basic_string<char>, boost::filesystem::path_traits>::string_type {aka class std::__cxx11::basic_string<char>}’ has no member named ‘string’
         string filename = filepath.filename().string();

我在两台机器上都安装了相同版本的 boost(1.55 和 1.59)。我不确定为什么我的机器上没有出现错误,但节点上却出现了错误。在这方面的任何帮助将不胜感激。

编辑 1: 以下是我的路径变量设置:

PATH=/home/head/cmp/soft/sft/boost_1_59_0:/home/head/cmp/soft/sft/boost_1_55_0/bin:/home/head/cmp/soft/sft/gcc/bin:$PATH

【问题讨论】:

    标签: c++ boost


    【解决方案1】:

    在我看来,节点上似乎安装了旧版本的 boost。旧版本的 boost::filesystem::path 没有 string 成员函数。 检查包含路径,编译器从某处获取错误的标头。 您可以在 gcc 命令行中添加一些额外的参数,以查看实际使用了哪些包含文件。看: /show include equivalent option in g++

    【讨论】:

    • 该节点之前没有安装任何版本的boost...我确定...并且我个人安装了两个boost版本...顺便说一句,我如何找出哪个boost版本正在使用(或安装)??
    • 此外,我正在使用 g++ 的 -MMD 版本...另外,我已在本地安装 gcc (g++) 并已包含在我的路径变量中...
    • 我 99% 确定某处包含错误的标题。尝试列出编译器使用的所有包含:stackoverflow.com/questions/4479049/…
    • 你的意思是使用 gcc 的 -H 选项?
    • 顺便说一句:PATH 变量通常(这确实是一些奇怪的设置)不用于解析任何包含路径。通常它类似于 INCLUDE。取决于操作系统/构建系统/ ...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多