I am new to boost. I am trying to follow a tutorial to learn how to obtain all the files in a directory. I have finally gotten it to find the header file but I cannot get this simple tutorial script to compile. I have read over similar errors but none of them are over the directory_iterator that I am trying to use.
I am using a TACC super computer. I module load boost/1.68. I even copied it into an include directory in my directory. I need my code to compile with the iclc compiler. I cannot use g++ or clang. This is a requirement for my class project that I am trying to use the filesystem for.
I am unable to just use the regular #include. the icpc compiler doesn't find the header file and I am unsure about how to go about finding it.
This is how I compile my code.
icpc -I ./include/boost scratch_fs.cpp
Here is my code
#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;
}
Here is the error message I get
/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'
Any help is much appreciated!