Boost logo

Boost :

Subject: [boost] Pre-compiled headers, Boost.Thread, and boost/date_time/date_facet.hpp
From: Patrick Hartling (patrick_at_[hidden])
Date: 2009-08-04 13:21:14


I am using Boost 1.39.0 with Visual C++ 9.0 SP1, and I am having problems
with pre-compiled headers that include boost/date_time/date_facet.hpp. I
have code organized into several DLLs, and one of the lowest level DLLs in
that set has a header file that, as of yesterday, includes headers from
Boost.Thread. The highest level DLL provides Python bindings made using
Boost.Python for all of the other DLLs. We use pre-compiled headers to get a
dramatic speed up of the build of the code that uses Boost.Python, and that
was working like a charm until Boost.Thread headers came into the mix. Now,
I get this linker error for every object file in the Python bindings DLL:

error LNK2001: unresolved external symbol "public: static class
std::locale::id boost::date_time::date_facet<class
boost::gregorian::date,char,class std::ostreambuf_iterator<char,struct
std::char_traits<char> > >::id"
(?id@?$date_facet_at_Vdate@gregorian_at_boost@@DV?$ostreambuf_iterator_at_DU?$char_traits_at_D@std@@@std@@@date_time_at_boost@@2V0locale_at_std@@A)

The only way that I have found to work around this is to keep anything that
might include boost/date_time/date_facet.hpp out of the headers that get
pre-compiled. At the moment, that is every Boost.Thread header I am using:
boost/thread/{thread,mutex,condition_variable}.hpp. It appears that most of
the key Boost.Thread headers end up including boost/thread/xtime.hpp, and
that header indirectly includes boost/date_time/date_facet.hpp.

Is there any way to work around this? I am not entirely sure what the
problem is, but my guess is that it has something to do with an aspect of
DLL symbol exporting and the way that the static data member
boost::date_time::date_facet<...>::id is defined. I think I ran into
something like this once (unrelated to Boost) a couple of years ago, but I
am still trying to track down that code.

 -Patrick

-- 
Patrick L. Hartling
Senior Software Engineer, Priority 5
http://www.priority5.com/



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