Boost logo

Boost :

Subject: [boost] [chrono] Header only library build and boost::system dependency
From: Edward Diener (eldiener_at_[hidden])
Date: 2016-05-04 00:05:41


The documentation for chrono says:

"How to Build Boost.Chrono as a Header Only Library?

When BOOST_CHRONO_HEADER_ONLY is defined the lib is header-only.

If in addition BOOST_USE_WINDOWS_H is defined <windows.h> is included,
otherwise files in boost/detail/win are used to reduce the impact of
including <windows.h>.

However, you will either need to define
BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING or link with Boost.System. "

So I have:

#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
#include <boost/chrono.hpp>

followed by some code using chrono, and I still get when linking my exe:

gcc.link
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.exe
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono.test\gcc-mingw-5.3\debug\test_chrono.o:
In function `_static_initialization_and_destruction_0':
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:221:
undefined reference to `boost::system::generic_category()'
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:222:
undefined reference to `boost::system::generic_category()'
E:\Programming\VersionControl\modular-boost\libs\cxx_dual\test/../../../boost/system/error_code.hpp:223:
undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status

Is there a way to use chrono without having to link boost::system ?


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