c++boostlinkermakefilejam

Building Boost date/time Jamfile with .v2 extension


I'm trying to build the Boost date_time library so I can link it in my Makefile. I'm in "libs/date_time/build" and see a lonely "Jamfile.v2", if I type jam I get:

Jamfile: No such file or directory
...found 7 target(s)...

I have no idea what to do now, I can't find anything about the date_time installation in the Boost documentation.

Here is the text in the document:

# Boost.date_time build and test Jamfile
#
#  Based on boost.python Jamfile
#
# To run all tests quietly: jam test
#
# Declares the following targets:
#   1. libboost_date_time, a static link library to be linked with all
#      Boost.date_time modules
#


project boost/date_time
    : requirements
        <define>DATE_TIME_INLINE
    <link>shared:<define>BOOST_ALL_DYN_LINK=1   
    <link>static:<define>BOOST_DATE_TIME_STATIC_LINK    
    : usage-requirements    
        <define>DATE_TIME_INLINE
        <link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
    : source-location ../src
    ;

# Base names of the source files for libboost_date_time
CPP_SOURCES = greg_month greg_weekday date_generators ;

lib boost_date_time : gregorian/$(CPP_SOURCES).cpp ;

boost-install boost_date_time ;

Thanks, Joe


Solution

  • Just to help anyone else trying to use the date_time library. You don't need to build anything, just include the needed header files in your code. If you get this error though:

    /usr/include/c++/4.6/boost/date_time/date_formatting.hpp:44: undefined reference to `boost::gregorian::greg_month::as_short_string() const'
    /usr/include/c++/4.6/boost/date_time/date_formatting.hpp:49: undefined reference to `boost::gregorian::greg_month::as_long_string() const'
    

    Just sudo into that file and comment out those lines. The document says that you need to write those functions yourself.