0

I am implementing a program using the Boost libraries. The program is compiled on different platforms. I have no problems on Mac OS.

The same code generates compiler errors on different platforms. The compilers are different: on Mac OS I use gcc 4.2, on Linux gcc 4.4, ...

However, there are some errors which are very hard to explain.

I am using Boost 1.5.3. For example, I have this strange message:

In member function 'std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >* FolderReader::get_filenames()':
/home/u/projects/prj/src/batch/folderreader.cpp:119: error: 
   'canonical' is not a member of 'bf'

where bf is defined as namespace bf = boost::filesystem;

and canonical() is invoked in this way: bf::canonical(pp).string() with pp set:

for(bf::directory_iterator it = bf::directory_iterator(p); it != bf::directory_iterator(); it++) {
    bf::path pp = *it;
...

However, it should work according to the API here: http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/reference.html#canonical


NOTE: Some other errors I have just corrected were of this type. I had to write:

obj.method1().method2()

as

class2 &obj2 = obj.method1();
obj2.method2();

otherwise I would receive an error message.

So... what's wrong with my invocation of boost::filesystem::canonical(...) ?

Antonio Sesto
  • 2,868
  • 5
  • 33
  • 51

1 Answers1

2

I would make sure that you are using version 3 of boost::filesystem, which was a significant change including the addition of canonical(). You may need to upgrade your boost installation or define BOOST_FILESYSTEM_VERSION to get V3.

Even if you have boost 1.53 installed you'll need to make sure that your code is being built against it. Your OS may have a default version that is being picked up. For example, the Debian squeeze repository (the current stable release) is on boost 1.42 which does not contain boost::filesystem V3 at all.

Community
  • 1
  • 1
rhashimoto
  • 15,650
  • 2
  • 52
  • 80