5

I am trying to compile the (thomas pevny's source code to calculate the subtractive pixels adjacency matrix). This code asks to previously install the libboost and libpng library, which i done successfully.

but when I do the 'make' command, the following errors appears on the terminal.

spam.cpp:169:26: error: ‘class boost::filesystem3::directory_entry’ has no member named ‘leaf’
spam.cpp:179:20: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string

Is there a way to fix this problem? Should I install another libboost version?

thanks for your attention.

3 Answers 3

6

leaf() is deprecated.

See this list of functions that are deprecated and their new names:

http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v2/doc/index.htm

Edit for commment:

It should be something like this:

  boost::filesystem::path p("foo.txt");
  std::cout << p.filename() << std::endl; 
Sign up to request clarification or add additional context in comments.

4 Comments

I corrected the second error by replacing native_file_string with file_string(), but when I replace leaf() with path().filename(), there is another error. The piece of code is: string fileName=file->path().filename(); //it was file->leaf() before.
The error is somethink like this: spam.cpp:168:42: error: conversion of ‘boost::filesystem3::path’ to non scalar type ‘std::string {aka std::basic_string<char>}’ required
Thank you again salgar. But I want the code to run independently of the file name (i don want to inform the file name directly on the code). Is there a good way to change this piece of code? thank you again.
The piece of code is string fileName=file->path().filename(). Should I convert file->path().filename() to string?
2

leaf() is deprecated. See: http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/reference.html#directory_iterator-members You can try to play without BOOST_FILESYSTEM_NO_DEPRECATED.

3 Comments

Thanks for your reply. I corrected the second error by replacing native_file_string with file_string(), but when I replace leaf() with path().filename(), there is another error. The piece of code is: string fileName=file->path().filename(); //it was file->leaf() before. the variable file is a directory iterator. The error is The error is somethink like this: spam.cpp:168:42: error: conversion of ‘boost::filesystem3::path’ to non scalar type ‘std::string {aka std::basic_string<char>}’ required
path.filename() is not of type String it is of type path. If you want to get the String from it you can try native() (path.filename().native()).
Thanks again for your reply. Now I have the following error: spam.cpp:168:30: error:‘((boost::iterator_facade<boost::filesystem3::directory_iterator, boost::filesystem3::directory_entry, boost::single_pass_traversal_tag>*)(& file))->boost::iterator_facade<I, V, TC, R, D>::operator-><boost::filesystem3::directory_iterator, boost::filesystem3::directory_entry, boost::single_pass_traversal_tag, boost::filesystem3::directory_entry&, long int>()->boost::filesystem3::directory_entry::path’ does not have class type. I will keep on trying to fix it, thank you again.
0

The problem was solved with @Salgar and @Jean-Baptiste Yunès suggestions and also by adding -lboost_system after -lboost_filesystem in makefile. Thank you everybody.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.