# Build-Compiler Information

Overview -- Compilation Options -- Compiler/Portability Notes -- Directory Structure -- Required Boost Libraries

Overview

The library has a few functions that require the creation of a library file (mostly to_string, from_string functions). Most library users can make effective use of the library WITHOUT building the library, but simply including the required headers. If the library is needed, the Jamfile in the build directory will produce a "static" library (libboost_date_time) and a "dynamic/shared" library (boost_date_time) that contains these functions. Note that to use the library without the library (particularly on windows) may require using the BOOST_DATE_TIME_NO_LIB flag to the compilation options.

Compilation Options

By default the posix_time system uses a single 64 bit integer internally to provide a microsecond level resolution. As an alternative, a combination of a 64 bit integer and a 32 bit integer (96 bit resolution) can be used to provide nano-second level resolutions. The default implementation may provide better performance and more compact memory usage for many applications that do not require nano-second resolutions.

To use the alternate resolution (96 bit nanosecond) the variable `BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG` must be defined in the library users project files (ie Makefile, Jamfile, etc). This macro is not used by the Gregorian system and therefore has no effect when building the library.

As of version 1.33, the date_time library introduced a new IO streaming system. Some compilers are not capable of utilizing this new system. For those compilers the earlier ("legacy") IO system is still available. Non-supported compilers will select the legacy system automatically but the user can force the usage of the legacy system by defining `USE_DATE_TIME_PRE_1_33_FACET_IO`.

As a convenience, `date_time` has provided some additional duration types. Use of these types may have unexpected results due to the snap-to-end-of-month behavior (see Reversibility of Operations Pitfall for complete details and examples). These types are enabled by default. To disable these types, simply undefine `BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES` in your project file.

Another convenience is the default constructors for `date`, and `ptime`. These constructors are enabled by default. To disable them, simply define `DATE_TIME_NO_DEFAULT_CONSTRUCTOR` in your project file.

Compiler/Portability Notes

The Boost Date-Time library has been built and tested with many compilers and platforms. However, some compilers and standard libraries have issues. While some of these issues can be worked around, others are difficult to work around. The following compilers are known to fully support all aspects of the library:

- Codewarrior 9.4 Windows
- GCC 3.2 - 3.4, 4.x on Linux
- GCC 3.3, 4.x on Darwin
- GCC 3.3 - 3.4, 4.x on Solaris
- GCC 3.3, 4.x on HP-UX
- QCC 3.3.5 on QNX
- MSVC 7.1 Windows
- Intel 8.1-9.x Linux and Windows

Unfortunately, the VC8 compiler has some issues with date-time code. The most serious issue is a memory leak which was introduced into the VC8 standard library basic_stream code. Date-time has code has been changed to avoid this as much as possible, but if you are using the legacy IO option (NOT the default with VC8) then the issue can still arise. See the

mailing list archive for more details.

In addition to the problem above, some versions of the VC8 library have limited the range of allowed values in the `std::tm` structure to positive values. This was a new restriction added in the VC8. The effect is that dates prior to the year 1900 will cause exceptions. There is, unfortunately, no easy workaround for this issue. Note that the new 64bit version of the VC8 compiler does not appear to have this limitation.

These compilers support all aspects of the library except `wstring/wstream` output.

- MinGW 3.2, 3.4, 3.5 *
- GCC 3.2 (cygwin) *

In particular, a lack of support for standard locales limits the ability of the library to support iostream based input output. For these compilers a set of more limited string based input-output is provided. Some compilers/standard libraries with this limitation include:

- Borland 5.6

Official support for some older compilers has now been dropped. This includes:

- GCC 2.9x
- Borland 5.1.1
- MSVC 7.0 and 6 SP5

Visual Studio & STLPort

There is a known issue with Visual Studio (7.0 & 7.1) and STLPort. The build errors typically make reference to a type issue or 'no acceptable conversion' and are attempting to instantiate a template with `wchar_t`. The default build of STLPort does not support `wchar_t`. There are two possible workarounds for this issue. The simplest is the user can build date_time with no wide stream/string etc. The other is to rebuild STLPort with wchar_t support.

To build date_time with no wide stream/string etc, execute the following command from `$BOOST_ROOT`:

    bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \
         "-sBUILD=<define>BOOST_NO_STD_WSTRING"           \
         --stagedir=... --with-date_time stage

(replace the ellipsis with the correct paths for the build system and adjust the `TOOLS` to the proper toolset if necessary)

Rebuilding STLPort with `wchar_t` support involves placing `/Zc:wchar_t` in the STLPort makefile. Date_time should then be built with the following command from `$BOOST_ROOT`:

    bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \
         "-sBUILD=&native-wchar_t>on"                     \
         --stagedir=... --with-date_time stage

(replace the ellipsis with the correct paths for the build system and adjust the `TOOLS` to the proper toolset if necessary)

Directory Structure

The directory tree has the following structure:

    /boost/date_time                   -- common headers and template code
    /boost/date_time/gregorian         -- Gregorian date system header files
    /boost/date_time/posix_time        -- Posix time system headers
    /boost/date_time/local_time        -- Local time system headers
    /libs/date_time/build              -- build files and output directory
    /libs/date_time/test               -- test battery for generic code
    /libs/date_time/test/gregorian     -- test battery for the Gregorian system
    /libs/date_time/test/posix_time    -- test battery for the posix_time system
    /libs/date_time/test/local_time    -- test battery for the local_time system
    /libs/date_time/example/gregorian  -- example programs for dates
    /libs/date_time/example/posix_time -- time example programs
    /libs/date_time/example/local_time -- nifty example programs
    /libs/date_time/src/gregorian      -- cpp files for libboost_date_time
    /libs/date_time/src/posix_time     -- empty (one file, but no source code...)

Required Boost Libraries

Various parts of date-time depend on other boost libraries. These include:

- boost.tokenizer
- boost.integer(cstdint)
- boost.operators
- boost.lexical_cast
- boost.smart_ptr (local time only)
- boost::string_algorithms
- boost::serialize (serialization code only)

so these libraries need to be installed.