Boost logo

Boost :

From: Christian Körber (koerber_at_[hidden])
Date: 2003-09-19 05:12:31


Hi,

I have encountered linking problems with the date_time
library which I cannot resolve myself.

Other libraries like shared_ptr work fine, though.

I use VC7 (.NET 2002)

Here's what I did:

1. downloaded and installed boost the complete 1.30.2

2. added boost to the include path

3. in the jamfile I commented the line
   local DATE_TIME_PROPERTIES =
<define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG ;
   in order to enable the 64-bit integer only implementation.

   Here I encountered the first problem: In the jamfile
   (included at the end of this mail) it says not only
   to comment this line but also to "out comment" a line
   "above". I could not identify such a line.

4. invoked bjam to build all boost libraries including
   date_time by bjam "-sTOOLS=msvc". I later tried
   bjam "-sTOOLS=vc7" which probably did the same as
   I have only VC7 installed (and not VC6 too).

5. I added
   boost-1.30.2\libs\date_time\build\bin\
   libboost_date_time.lib\msvc\debug\runtime-link-dynamic\
   libboost_date_time.lib
   as an input libryry to the linker (project properties).

6. I tried to build one of the sample programs, short
   version here, complete one at the end of this mail.

   #include "boost/date_time/posix_time/posix_time.hpp"
   #include <iostream>

   int main()
   {
      using namespace boost::posix_time;
      using namespace boost::gregorian;

      date d(2002,Feb,1); //an arbitrary date
      //construct a time by adding up some durations durations
      ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));

      std::cout << to_simple_string(t1);

      return 0;
    }

   This resulted in several warnings, mostly due to the
   conversion of larger intagral types to smaller one
   (possible loss of data) and the following linker
   errors(edited):

   A:
   error LNK2005: "private: __thiscall type_info::type_info(
   class type_info const &)" (??0type_info@@AAE_at_ABV0@@Z)
   already defined in LIBCD.lib(typinfo.obj)

   B:
   error LNK2005: "private: class type_info & __thiscall
   type_info::operator=(class type_info const &)"
   (??4type_info@@AAEAAV0_at_ABV0@@Z)
   already defined in LIBCD.lib(typinfo.obj)

   C:
   warning LNK4098: defaultlib 'MSVCRTD' conflicts with
   use of other libs; use /NODEFAULTLIB:library

   D:
   fatal error LNK1169: one or more multiply defined symbols
   found

   This means to me that some functions of type_info are
   both defined in the stdlib of VC7 and somewhere in
   boost.
   I have no idea about how to resolve this issue. I tried
   to link with /NODEFAULTLIB but this gave me much much
   more linker errors than I had before.

   Any suggestion are highly appreciated,

   Christian Koerber

JAMFILE START

# (C) Copyright 2002. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice
appears
# in all copies. This software is provided "as is" without express or
implied
# warranty, and with no claim as to its suitability for any purpose.
#
#
# Boost.date_time build
#
# To run all tests quietly: jam test
#
# Declares the following targets:
# 1. libboost_date_time, a library to be linked with all
# Boost.date_time modules
#

# declare the location of this subproject relative to the root
subproject libs/date_time/build ;

# comment the line below and comment out the line above to change to
# 64 bit counted time implementation

local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG ;

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

dll boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
    : <sysinclude>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
    : debug release
    ;

lib boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
    : <sysinclude>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
    : debug release
    ;

JAMFILE END

ORIGINAL SAMPLE PROGRAM START

   #include "boost/date_time/posix_time/posix_time.hpp"
   #include <iostream>

   int main()
   {
      using namespace boost::posix_time;
      using namespace boost::gregorian;

      date d(2002,Feb,1); //an arbitrary date
      //construct a time by adding up some durations durations
      ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
      //construct a new time by subtracting some times
      ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(1);
      //construct a duration by taking the difference between times
      time_duration td = t2 - t1;

      std::cout << to_simple_string(t2) << " - "
         << to_simple_string(t1) << " = "
         << to_simple_string(td) << std::endl;

      return 0;
    }

ORIGINAL SAMPLE PROGRAM END


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk