While building MongoDB with SCons and boost, I'm getting errors. Here's my command line:
C:\mongo-cxx-driver>Scons --prefix=$HOME/mongo-client-lib --cpppath=C:\boost_1_66_0 --libpath=C:\boost_1_66_0\stage64\lib --dbg=on --64 install
Here are the error messages I'm getting:
src\mongo\util\time_support.cpp(904): error C2039: 'winapi': is not a member of 'boost::date_time'
C:\boost_1_66_0\boost/date_time/filetime_functions.hpp(28): note: see declaration of 'boost::date_time'
src\mongo\util\time_support.cpp(904): error C3083: 'winapi': the symbol to the left of a '::' must be a type
src\mongo\util\time_support.cpp(904): error C2039: 'file_time_to_microseconds': is not a member of 'boost::date_time'
C:\boost_1_66_0\boost/date_time/filetime_functions.hpp(28): note: see declaration of 'boost::date_time'
src\mongo\util\time_support.cpp(904): error C3861: 'file_time_to_microseconds': identifier not found
src\mongo\util\time_support.cpp(936): error C2039: 'winapi': is not a member of 'boost::date_time'
C:\boost_1_66_0\boost/date_time/filetime_functions.hpp(28): note: see declaration of 'boost::date_time'
src\mongo\util\time_support.cpp(936): error C3083: 'winapi': the symbol to the left of a '::' must be a type
src\mongo\util\time_support.cpp(936): error C2039: 'file_time_to_microseconds': is not a member of 'boost::date_time'
C:\boost_1_66_0\boost/date_time/filetime_functions.hpp(28): note: see declaration of 'boost::date_time'
src\mongo\util\time_support.cpp(936): error C3861: 'file_time_to_microseconds': identifier not found
scons: *** [build\win32\64\dbg_on\mongo\util\time_support.obj] Error 2
scons: building terminated because of errors.
TL; DR - You can't expect to pick an arbitrary or current version of a library and build MongoDB with it; they snapshot their dependencies in their repo and there's no promises about building with versions besides those.
MongoDB has snapshots of its dependencies in the src/thirdparty directory. The version of boost snapshotted there is 1.60, which was released in 2015. You can see that in that version of boost, there is a winapi
namespace defined in boost/date_time/filetime_functions.hpp
.
However, you're trying to build against boost 1.66, which was released in December 2017. The release notes mention changes to date_time:
DateTime:
The library has been converted to use Boost.WinAPI as the abstraction layer for Windows SDK.
Fixed an integral overflow that could cause incorrect results when adding or subtracting many years from a date (see here).
That version of filetime_functions does not have this namespace inside of date_time, nor does the current 1.67 snapshot of filetime_functions.hpp.
Looking at the git blame log for src/mongo/util/time_support.cpp, it looks like the mongo code in question mentioning date_time::winapi
was added 3 years ago (before this winapi refactoring) and hasn't changed since.