错误boost::文件系统没有名为string()的成员
error boost::filesystem has no member named string()
我正试图在我的机器(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
对我来说,节点上似乎安装了旧版本的boost。旧版本的boost::filesystem::path没有string
成员函数。检查include路径,编译器会从某个地方得到错误的头。您可以在gcc命令行中添加一些额外的参数,以查看实际使用了哪些包含文件。请参阅:/在g++中显示包含等效选项
相关文章:
- 反转没有循环的字符串,C++中只有 std::string 成员
- C++ 入门 12.1:我可以在类中使用静态向量成员实现 StrBlob<string> 吗?
- 使用<string>提升::序列化序列化具有 vector<unique_ptr> 成员的类
- 如何使用<string>初始值设定项列表初始化unordered_map<字符串、unordered_set>成员?
- C++ 错误:'std::string'没有成员
- 我应该如何处理:错误 C2039 "分配":不是 Visual Studio 2017 中"cl::string"的成员?
- 'struct std::string'没有名为'c_string'的成员
- 在结构的联合成员中使用std::string时,无法引用默认构造函数
- 如何将STD :: String的值复制到Char数组类型的结构成员
- 如何将 std::vector<std::string> 转换为 boost::spirit 中结构的成员?
- std::string::substr成员函数的复杂性是什么?
- 不要使用 "const char *" 作为类的成员,如果你真的是"std::string"
- 获取指向成员std::string::size的指针无法与libc++链接,但可以与libstdc++一起使用
- 工会不会接受第 'string' 类成员
- std::string 作为成员函数的参数的奇怪行为
- 使用 move std::string 的 .data() 成员不适用于小字符串?
- 如何创建静态常量成员 std::string 数组
- 当传入具有std::string成员的结构时,C++-gdb会给出意外的输出
- 结构体的std::string成员的EXC_BAD_ACCESS错误
- 为什么push_back会在上行对象的string成员中抛出一个char ?