buildwt

Compile Wt on macos fails with boost::filesystem::directory_iterator end_itr


When building Wt on Macos according to steps outlined in Installation: Unix-like platforms (Linux, macOS, BSD,...) I'm hitting this error and the build ends without completing outputting the below error messages. Any feedback on this error is appreciated.

no member named 'directory_iterator'

build steps:

%> cd <wt/download/directory>
%> mkdir build
%> cd build
%> cmake ../
%> make -j8

When following this procesures the make step fails with the following:

[ 69%] Building CXX object src/CMakeFiles/wt.dir/web/SslUtils.C.o
/Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:82:26: error: no type named 'directory_iterator' in namespace 'boost::filesystem'; did you mean 'directory_entry'?
   82 |       boost::filesystem::directory_iterator end_itr;
      |       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                          directory_entry
/usr/local/include/boost/filesystem/detail/path_traits.hpp:51:7: note: 'directory_entry' declared here
   51 | class directory_entry;
      |       ^
/Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:82:45: error: variable has incomplete type 'boost::filesystem::directory_entry'
   82 |       boost::filesystem::directory_iterator end_itr;
      |                                             ^
/usr/local/include/boost/filesystem/detail/path_traits.hpp:51:7: note: forward declaration of 'boost::filesystem::directory_entry'
   51 | class directory_entry;
      |       ^
/Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:91:31: error: no member named 'directory_iterator' in namespace 'boost::filesystem'
   91 |       for (boost::filesystem::directory_iterator i(path); i != end_itr; ++i) {
      |            ~~~~~~~~~~~~~~~~~~~^
/Users/thomaspeters/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:91:59: error: use of undeclared identifier 'i'
   91 |       for (boost::filesystem::directory_iterator i(path); i != end_itr; ++i) {
      |                                                           ^
/Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:91:75: error: use of undeclared identifier 'i'
   91 |       for (boost::filesystem::directory_iterator i(path); i != end_itr; ++i) {
      |                                                                           ^
/Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:92:27: error: use of undeclared identifier 'i'
   92 |         std::string f = (*i).path().string();
      |                           ^
1 warning and 6 errors generated.

Boost Version:

10-85-00

I was able to successfull build and install Boost using bootstrap and b2 install.

Macos version:

ProductName:        macOS
ProductVersion:     15.0
BuildVersion:       24A5298h

Processor:

2.3 GHz 8-Core Intel Core i9

Wt version:

wt-4.10.4

Solution

  • Note the crux of the error message:

    /Users/user1/Development/C-Projects/wt-4.10.4/src/web/FileUtils.C:82:26: error: no type named 'directory_iterator' in namespace 'boost::filesystem'; did you mean 'directory_entry'?
       82 |       boost::filesystem::directory_iterator end_itr;
          |       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
          |                          directory_entry
    

    This is because wt-4.10.4/src/web/FileUtils.C is missing an include statement for boost::filesystem. Add it yourself to line 10 in that file, à la.:

      /*
       * Copyright (C) 2012 Emweb bv, Herent, Belgium.
       *
       * See the LICENSE file for terms of use.
       */
    
      #include "web/FileUtils.h"
    
      #include <boost/filesystem/operations.hpp>
      #include <boost/filesystem.hpp>             // <-- add this line
    
      #include "web/WebUtils.h"
      #include "Wt/WException.h"
      #include "Wt/WLogger.h"
    

    Afterwards, run make again and wt-4.10.4/src/web/FileUtils.C will compile fine.

    This is a bug in wt-4.10.4 and you should report it to them as such.

    Note that there are other issues in wt-4.10.4 that will prevent it from fully building.