[Boost-bugs] [Boost C++ Libraries] #12176: Chrono without linking to Boost.System

Subject: [Boost-bugs] [Boost C++ Libraries] #12176: Chrono without linking to Boost.System
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-05-04 13:06:01

#12176: Chrono without linking to Boost.System
 Reporter: eldiener | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
 In the chrono docs we have:

 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

 But when I followed this chrono still linked with Boost.System. Here is
 the code:


 #include <iostream>
 #include <boost/chrono.hpp>
 #include <boost/ratio.hpp>

 int main()
   typedef boost::chrono::duration<int, boost::ratio<1, 100000000> >
   typedef boost::chrono::duration<int, boost::centi> jiffies;
   typedef boost::chrono::duration<float, boost::ratio<12096,10000> >
   typedef boost::chrono::duration<float, boost::ratio<3155,1000> >
   boost::chrono::seconds sec(1);
   std::cout << "1 second is:\n";
   std::cout << boost::chrono::duration_cast<shakes>(sec).count()
               << " shakes\n";
   std::cout << boost::chrono::duration_cast<jiffies>(sec).count()
               << " jiffies\n";
   std::cout << microfortnights(sec).count() << " microfortnights\n";
   std::cout << nanocenturies(sec).count() << " nanocenturies\n";
   return 0;

 The link error message is:

 gcc.link C:\Programming\VersionControl\modular-
 mingw-5.3\debug\test_chrono_boost.o: In function
 undefined reference to `boost::system::generic_category()'
 undefined reference to `boost::system::generic_category()'
 undefined reference to `boost::system::system_category()'
 collect2.exe: error: ld returned 1 exit status

 If I uncomment the line:


 then chrono links without requiring Boost.System.

 Maybe this bug is one of documentation and the documentation should be
 changed to specify that BOOST_SYSTEM_NO_DEPRECATED must also be defined in
 order to remove the chrono dependency on Boost.System.

Ticket URL: <https://svn.boost.org/trac/boost/ticket/12176>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC