无法编译:对`boost :: filesystem :: detail :: directory_iterator_construct的未定义引用

时间:2019-05-14 20:56:33

标签: c++ compiler-errors boost-filesystem

我是新人。我正在尝试按照教程学习如何获取目录中的所有文件。我终于得到它来找到头文件,但是我无法编译这个简单的教程脚本。我已阅读过类似的错误,但没有一个错误遍及我要使用的directory_iterator。

我正在使用TACC超级计算机。我模块负载提升为1.68。我什至将其复制到目录中的include目录中。我需要我的代码才能使用iclc编译器进行编译。我不能使用g ++或clang。这是我尝试使用文件系统的班级项目的要求。

我不能只使用常规的#include。 icpc编译器找不到头文件,我不确定如何去找到它。

这就是我编译代码的方式。

icpc -I ./include/boost scratch_fs.cpp 

这是我的代码

#include <string>
#include <iostream>
#include "boost/filesystem.hpp"
#include <fstream>


using namespace boost::filesystem;

int main()
{
    std::string path = "/path/to/directory";
    for (auto & entry : directory_iterator(path))
        std::cout << entry.path() << std::endl;
}

这是我收到的错误消息

/tmp/icpcMNLwud.o: In function `main':
scratch_fs.cpp:(.text+0x1b4): undefined reference to `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
scratch_fs.cpp:(.text+0x3cb): undefined reference to `boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)'
/tmp/icpcMNLwud.o: In function `void boost::checked_delete<boost::filesystem::detail::dir_itr_imp>(boost::filesystem::detail::dir_itr_imp*)':
scratch_fs.cpp:(.text._ZN5boost14checked_deleteINS_10filesystem6detail11dir_itr_impEEEvPT_[_ZN5boost14checked_deleteINS_10filesystem6detail11dir_itr_impEEEvPT_]+0x19): undefined reference to `boost::filesystem::detail::dir_itr_close(void*&, void*&)'
/tmp/icpcMNLwud.o: In function `boost::detail::sp_counted_impl_p<boost::filesystem::detail::dir_itr_imp>::dispose()':
scratch_fs.cpp:(.text._ZN5boost6detail17sp_counted_impl_pINS_10filesystem6detail11dir_itr_impEE7disposeEv[_ZN5boost6detail17sp_counted_impl_pINS_10filesystem6detail11dir_itr_impEE7disposeEv]+0x17): undefined reference to `boost::filesystem::detail::dir_itr_close(void*&, void*&)'
/tmp/icpcMNLwud.o: In function `boost::system::error_category::std_category::equivalent(std::error_code const&, int) const':
scratch_fs.cpp:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0x34): undefined reference to `boost::system::detail::generic_category_instance'
scratch_fs.cpp:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0x9e): undefined reference to `boost::system::detail::generic_category_instance'
scratch_fs.cpp:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0xea): undefined reference to `boost::system::detail::generic_category_instance'
/tmp/icpcMNLwud.o: In function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':
scratch_fs.cpp:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0x2b): undefined reference to `boost::system::detail::generic_category_instance'
scratch_fs.cpp:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0xa8): undefined reference to `boost::system::detail::generic_category_instance'

非常感谢您的帮助!

0 个答案:

没有答案