vendredi 29 avril 2016

Problems with boost library and c++11

I am trying to learn how boost filesystem work, but I can't get through some compilation problems

#include <boost/filesystem.hpp>
#include <iostream>

using namespace boost::filesystem;

int main()
{
  path p = current_path();
  directory_iterator it{p};
  while (it != directory_iterator{})
    std::cout << *it++ << '\n';
}

this is how I try to compile. My g++ version is 4.7

g++ -std=c++11 filesystem.cc -lboost_filesystem  -o filesystem 

After this I get thousands of errors. For example

In file included from /usr/include/boost/filesystem/path.hpp:23:0,
                 from /usr/include/boost/filesystem/operations.hpp:17,
                 from /usr/include/boost/filesystem.hpp:16,
                 from filesystem.cc:1:
/usr/include/boost/throw_exception.hpp: In instantiation of ‘void boost::throw_exception(const E&) [with E = boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::basic_string<char>, boost::filesystem::path_traits> >]’:
/usr/include/boost/filesystem/operations.hpp:280:9:   required from ‘typename boost::enable_if<boost::filesystem::is_basic_path<Path>, boost::filesystem::file_status>::type boost::filesystem::symlink_status(const Path&) [with Path = boost::filesystem::basic_path<std::basic_string<char>, boost::filesystem::path_traits>; typename boost::enable_if<boost::filesystem::is_basic_path<Path>, boost::filesystem::file_status>::type = boost::filesystem::file_status]’

Aucun commentaire:

Enregistrer un commentaire