Boost C++ Libraries: Ticket #12176: Chrono without linking to Boost.System
https://svn.boost.org/trac10/ticket/12176
<p>
In the chrono docs we have:
</p>
<pre class="wiki">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.
</pre><p>
But when I followed this chrono still linked with Boost.System. Here is the code:
</p>
<pre class="wiki">#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
// #define BOOST_SYSTEM_NO_DEPRECATED
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/ratio.hpp>
int main()
{
typedef boost::chrono::duration<int, boost::ratio<1, 100000000> > shakes;
typedef boost::chrono::duration<int, boost::centi> jiffies;
typedef boost::chrono::duration<float, boost::ratio<12096,10000> > microfortnights;
typedef boost::chrono::duration<float, boost::ratio<3155,1000> > nanocenturies;
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;
}
</pre><p>
The link error message is:
</p>
<pre class="wiki">gcc.link C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono_boost.test\gcc-mingw-5.3\debug\test_chrono_boost.exe
C:\Programming\VersionControl\modular-boost\build\boost\bin.v2\libs\cxx_dual\test\test_chrono_boost.test\gcc-mingw-5.3\debug\test_chrono_boost.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
</pre><p>
If I uncomment the line:
</p>
<pre class="wiki">// #define BOOST_SYSTEM_NO_DEPRECATED
</pre><p>
then chrono links without requiring Boost.System.
</p>
<p>
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.
</p>
en-usBoost C++ Libraries/htdocs/site/boost.png
https://svn.boost.org/trac10/ticket/12176
Trac 1.4.3Edward DienerWed, 04 May 2016 13:06:32 GMTcomponent changed; owner set
https://svn.boost.org/trac10/ticket/12176#comment:1
https://svn.boost.org/trac10/ticket/12176#comment:1
<ul>
<li><strong>owner</strong>
set to <span class="trac-author">viboes</span>
</li>
<li><strong>component</strong>
<span class="trac-field-old">None</span> → <span class="trac-field-new">chrono</span>
</li>
</ul>
TicketviboesWed, 04 May 2016 22:02:00 GMTstatus changed
https://svn.boost.org/trac10/ticket/12176#comment:2
https://svn.boost.org/trac10/ticket/12176#comment:2
<ul>
<li><strong>status</strong>
<span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span>
</li>
</ul>
<p>
Hi,
</p>
<p>
please could you check if this
<a class="ext-link" href="https://github.com/boostorg/chrono/commit/6f34fae179795bd449f4921b0de837b05b17022d"><span class="icon"></span>https://github.com/boostorg/chrono/commit/6f34fae179795bd449f4921b0de837b05b17022d</a>
solves the issue?
</p>
TicketEdward DienerThu, 05 May 2016 10:24:18 GMT
<link>https://svn.boost.org/trac10/ticket/12176#comment:3 </link>
<guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12176#comment:3</guid>
<description>
<p>
The latest change on develop fixes the issue.
</p>
</description>
<category>Ticket</category>
</item>
<item>
<dc:creator>viboes</dc:creator>
<pubDate>Mon, 09 May 2016 06:05:27 GMT</pubDate>
<title>milestone changed
https://svn.boost.org/trac10/ticket/12176#comment:4
https://svn.boost.org/trac10/ticket/12176#comment:4
<ul>
<li><strong>milestone</strong>
<span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.62.0</span>
</li>
</ul>
TicketviboesFri, 19 Aug 2016 21:12:22 GMTstatus changed; resolution set
https://svn.boost.org/trac10/ticket/12176#comment:5
https://svn.boost.org/trac10/ticket/12176#comment:5
<ul>
<li><strong>status</strong>
<span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span>
</li>
<li><strong>resolution</strong>
→ <span class="trac-field-new">fixed</span>
</li>
</ul>
Ticket