
Dear advanced boost/c/g++ programers: I copied and try a simple (Reading a directory with boost) program , from page 383, Example 10-19, of book(C++ cookbook) ----------you can download the code to try by yourself at, http://examples.oreilly.com/9780596007614/ // Example 10-19. Reading a directory #include <iostream> #include <cstdlib> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/fstream.hpp> using namespace boost::filesystem; int main(int argc, char** argv) { if (argc < 2) { std::cerr << "Usage: " << argv[0] << " [dir name]\n"; return(EXIT_FAILURE); } path fullPath = // Create the full, absolute path name system_complete(path(argv[1])); if (!exists(fullPath)) { std::cerr << "Error: the directory " << fullPath.string() << " does not exist.\n"; return(EXIT_FAILURE); } if (!is_directory(fullPath)) { std::cout << fullPath.string() << " is not a directory!\n"; return(EXIT_SUCCESS); } directory_iterator end; for (directory_iterator it(fullPath); it != end; ++it) { // Iterate through each // element in the dir, std::cout << it->leaf(); // almost as you would if (is_directory(*it)) // an STL container std::cout << " (dir)"; std::cout << '\n'; } return(EXIT_SUCCESS); } ----------------------------------------------------------------------------- my compiler g++ 4.5.2 not pass it, even I link --------- eric@eric-laptop:~/cppcookbook/ch10$ g++ -lboost_system -lboost_filesystem Example10-19.cpp Example10-19.cpp: In function ‘int main(int, char**)’: Example10-19.cpp:34:24: error: ‘class boost::filesystem3::directory_entry’ has no member named ‘leaf’ eric@eric-laptop:~/cppcookbook/ch10$ --------- I am using 1.46.1 of boost looking to hear from your help and thanks a lot in advance, Eric